CoffeeScript: Check whether a given year is a leap year in the Gregorian calendar
CoffeeScript: Exercise-3 with Solution
Write a CoffeeScript program to determine whether a given year is a leap year in the Gregorian calendar.
HTML Code :
<!DOCTYPE html>
<html>
<head>
<script src="//jashkenas.github.io/coffee-script/extras/coffee-script.js"></script>
<meta charset="utf-8">
<title>Check whether a given year is a leap year in the Gregorian calendar</title>
</head>
<body>
</body>
</html>
CoffeeScript Code :
year = window.prompt('Input a Year : ')
x = if year % 100 == 0 then year % 400 == 0 else year % 4 == 0
console.log x
Sample Output:
true
Live Demo :
See the Pen coffeescript-exercise-3 by w3resource (@w3resource) on CodePen.
Improve this sample solution and post your code through Disqus.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/coffeescript-exercises/coffeescript-exercise-3.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics