xinconan / blog

闲谈
7 stars 0 forks source link

闰年的判断 #7

Open xinconan opened 6 years ago

xinconan commented 6 years ago

闰年的判断条件:

  1. 能被4整除,但不能被100整除
  2. 能被400整除
isLeapYear(year) {
  return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}