# Loop check of time in JavaScript

Let's find all the first numbers of the months of the current year that are Sunday:

`let now = new Date(); let year = now.getFullYear(); for (let month = 0; month <= 11; month++) { let date = new Date(year, month, 1); if (date.getDay() == 0) { console.log(year + '-' + month + '-1'); } }`

Consider the span from `2000`th to the current year. Determine how many times January `1`st fell on weekend in this interval, that is, on Saturday or Sunday.

←→
↑
en ru