w3resource logo


CoffeeScript exercises

CoffeeScript : Find which 1st January be a Sunday between a range of years

CoffeeScript : Exercise-5 with Solution

Write a CoffeeScript program to find 1st January be a Sunday between 2015 and 2050.

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 :

console.log '--------------------'
year = 2015
while year <= 2050
  d = new Date(year, 0, 1)
  if d.getDay() == 0
    console.log '1st January is being a Sunday  ' + year
  year++
console.log '--------------------'

Live Demo :

JS Bin

Post your code through Disqus



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

Help the community:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number