← Back to challenges

In N Days...

JavaScriptHarddatesarrays

Instructions

If today was Monday, in two days, it would be Wednesday.

Create a function that takes in an array of days as input and the number of days to increment by. Return an array of days after n number of days has passed.

Examples

afterNDays(["Thursday", "Monday"], 4) ➞ ["Monday", "Friday"]

afterNDays(["Sunday", "Sunday", "Sunday"], 1) ➞ ["Monday", "Monday", "Monday"]

afterNDays(["Monday", "Tuesday", "Friday"], 1) ➞ ["Tuesday", "Wednesday", "Saturday"]

Notes

  • Return as an array.
  • All test cases will have the first letter of each day capitalized.
  • n number of days may be greater than 7.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.