w3resource logo


CoffeeScript exercises

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.

Solution :

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="//jashkenas.github.io/coffee-script/extras/coffee-script.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</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
alert x

Live Demo :

JS Bin on jsbin.com

Post your code through Disqus



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program