Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. /**
  2. * 检查平润年,返回正确月份的天数
  3. * @param year 年份
  4. * @param month 月份
  5. * @returns {number} 该月正确的天数
  6. */
  7. function checkTime(year, month) {
  8. if (month === 2) return (year % 4 === 0 && year % 100 !== 0 || year % 400) === 0 ? 29 : 28;
  9. return '4;6;9;11'.indexOf(month + ';') === -1 ? 31 : 30;
  10. }
  11.  
  12. document.write(checkTime(2017,2));
  13. //最终打印出28
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement