Based on JS, use if-else to determine whether the year entered by the user is a leap year

Determine if the year entered by the user is a leap year (1000-3000)

Insert picture description here
console.log( 请输入2000-2020年之间的年份)
let inputyear = rs.question()-0;
if (inputyear >= 2000 && inputyear <= 2020) { (inputyear% 4 == 0 && inputyear% 100 == 0) || inputyear% 400 = = 0? Console.log( ): console.log( ); } else { console.log( ) } Note: For the time being, there is no consideration of limiting the input to integers, just input integers when trying to achieve judgment. Please understand if there are any deficiencies! !

您输入的${inputyear}是闰年您输入的${inputyear}不是闰年

您输入的${inputyear}有误,不在2000-2020年之间

Guess you like

Origin blog.csdn.net/dabaiZhang/article/details/108436475