const getDays = (month, year) => {...};
`month`
parameter is zero-based index. We can make the function quickly return if the month is April, June, September or November:if (month === 3 || month === 5 || month === 8 || month === 10) {return 30;}...
`Array.includes`
function:if ([3, 5, 8, 10].includes(month)) {return 30;}...
const isLeapYear = (year) => year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);const getDays = (month, year) => [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];