Sunday, April 18, 2021

11. Write a JavaScript program to find which 1st January is being a Sunday between 2014 and 2050.

11. Write a JavaScript program to find which 1st January is being a Sunday between 2014 and 2050.

<script>
console.log('--------------------');

for (var year = 2014; year <= 2050; year++)
    {

    var d = new Date(year, 0, 1);
    if ( d.getDay() === 0 )
        console.log("1st January is being a Sunday  "+year);
    }

console.log('--------------------');
</script>

No comments:

18 May 2021 Current Affairs