SHARE
TWEET

Untitled

a guest Jul 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top