What is your hint or solution suggestion?
solution
function countingSundays(firstYear, lastYear) {
let sundays = 0;
let date = new Date();
date.setFullYear(firstYear);
date.setDate(1);
date.setMonth(0);
while(date.getFullYear() != lastYear || date.getMonth() != 11 || date.getDate() != 2){
if(date.getDay() === 0 && date.getDate() === 1 ){
sundays++;
}
//skip entire month for shortening loop
if(date.getDate() === 2){
date.setDate(28);
}
date.setDate(date.getDate() + 1);
}
return sundays;
}
Challenge: Problem 19: Counting Sundays
Link to the challenge: