Views: 245
Following program shows you how take a year as input and tells whether it's a leap year or not.
var input = prompt("Enter a year:");
if (input % 4 == 0) {
if (input % 100 == 0) {
if (input % 400 == 0) {
console.log(input + " its a leap year");
} else {
console.log(input + " its not a leap year")
}
} else {
console.log(input + " its a leap year")
}
} else {
console.log(input + " its not a leap year")
}
Output:
Example1:
Enter a year:
1980
1980 its a leap year
Example2:
Enter a year:
2001
2001 its not a leap year
On By
Navya
Top Tutorials
492.5K
32K
21.8K
18.7K
18.7K
6.7K
6.7K
4.9K
3.3K
3.2K
Top Questions
18.7K
14.5K
8.3K
6.6K
6.2K
5.7K
4.8K
4.8K
4.3K
3.9K
Top Articles
1.9K
1.6K
947
Top Blogs
796
779
55
Top News
754
686
670
398
385
385