Answer:
function getDay(s, k) {
var weekDays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
var index = weekDays.findIndex(function(day) { return day === s; });
return weekDays[(index + k) % 7];
}
Explanation:
// This function takes two parameters:
// s: a string representing the current day of the week
// k: an integer indicating how many days after s to find the result
function getDay(s, k) {
var weekDays = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
// Find the index of day s in weekDays array
var index = weekDays.findIndex(function(day) { return day === s; });
// Calculate the new index by adding k and using modulo 7 to wrap around
return weekDays[(index + k) % 7];
}