Variable weekDaysList holds a list of weekdays, which are represented as strings.
Write a function that have 2 params:
- weekDayCurrent (STRING) - representing the day of the week for the current day
- and weekDaysLater (INTEGER) - representing how many days later
For example: if weekDayCurrent = “Tuesday” and weekDaysLater = 4, the function should return “Saturday”.
function weekDayLater(weekDayCurrent, weekDaysLater) { let weekDaysList = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']; // get the index of the weekday let weekDayIndex = weekDaysList.indexOf(weekDayCurrent); // get the index offset let moduloIndex = (weekDayIndex + weekDaysLater) % weekDaysList.length; return weekDaysList[moduloIndex]; }