daysInMonth
Gets the number of days in the given month
of the specified year
.
- Use the
new Date()
constructor to create a date from the givenyear
andmonth
. - Set the days parameter to
0
to get the last day of the previous month, as months are zero-indexed. - Use
Date.prototype.getDate()
to return the number of days in the givenmonth
.