JavaScript judge leap year

Time:2021-2-8

requirement:

Enter a year to judge whether it is a leap year (leap year: divisible by 4)alsoNot divisible by 100orYear divisible by 400

Code implementation:

//Using function to judge leap year
function isRunYear(year) {
    //Return true for leap year, otherwise return false 
    var flag = false;
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
        flag = true;
    }
    return flag;
}
Var year = number (prompt ('Please enter year: ');
alert(isRunYear(year));