Solution for Rosetta Code: Day of the week

Bug report of test issue has been filed at https://github.com/freeCodeCamp/freeCodeCamp/issues/39995

What is your hint or solution suggestion?
This could probably be refactored with ES6, but the main idea is recognizing the power of the Date object.

From the starting year to the end year, we find which days are Sundays by using new Date(i, 11, 25).getDay()==0, i is the year, and the months are from 0 to 11. getDay returns the day of the week, where Sunday is equal to 0.

Solution 1
function findXmasSunday(start, end) {
  var i;
  var extradays = [];
  for (i = start; i < end; i++) { 
    if(new Date(i, 11, 25).getDay()==0){
      extradays.push(i)
  }
}
  return extradays;
}

Challenge: Day of the week

Link to the challenge:

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

1 Like

I just submitted a report to GitHub