Table of Contents
show
Example: 1B
Write a JavaScript to determine whether a given year is a leap year in the Gregorian calendar.
Script
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: 11