daysInMonth function

int daysInMonth(
  1. int year,
  2. int month
)

Implementation

int daysInMonth(int year, int month) {
  const lengths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  if (month == 2 && isLeapYear(year)) return 29;
  return lengths[month - 1];
}