Number of days in any month

date, javascript

Solution

function getDaysInMonth(m, y) {
   return /8|3|5|10/.test(--m)?30:m==1?(!(y%4)&&y%100)||!(y%400)?29:28:31;
}

Problem

How can I write a JavaScript function that accepts a number from 1 - 12 representing the months of the year, and then returns the number of days in that month?

Original source

Related problems