Table of Contents
show
Example 12:
Write a JavaScript to check whether a year is leap or not
const prompt = require("prompt-sync")();
let year = prompt("Enter year");
year = parseInt(year);
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
console.log(`${year} is leap year`);
} else {
console.log(`${year} is not leap year`);
}
Output:
Views: 113