JSFiddle - React, Tailwind, and code Playground

by B L Praveen

JavaScript

function weeks_Of_Month( y, m ) {
    var first = new Date(y, m,1).getDay();      
    var last = 32 - new Date(y, m, 32).getDate(); 

    // logic to calculate number of weeks for the current month
    return Math.ceil( (first + last)/7 );   
}

alert(weeks_Of_Month(2014,1));