Sunday, April 18, 2021

10. Write a JavaScript program to determine whether a given year is a leap year in the Gregorian calendar.

10. Write a JavaScript program to determine whether a given year is a leap year in the Gregorian calendar.

<script>

year = window.prompt("Input a Year : ");
x = (year % 100 === 0) ? (year % 400 === 0) : (year % 4 === 0);
console.log(x);

</script>

No comments: