Dates in JavaScript [closed]

0

I have to print every year that January 1 falls on Sunday from the current year to 2080. How could it be done?

Example: In these years on January 1 is Sunday: 2020,2025,2030 ...

    
asked by InThaHouse 29.10.2018 в 16:27
source

1 answer

3

Easy.

for (i=2018; i <= 2080; i++) {
    var date = new Date('1/1/'+i);
    if(date.getDay() == 0) console.log(i);
}
    
answered by 29.10.2018 / 16:32
source