Respuesta :
Answer:
function getDay(s, k){
var weekDays = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];
var index=weekDays.findIndex(function(weekDay){return weekDay==s;});
return weekDays[(index+k)%7];
}
Explanation:
//this functions receive the next parameters:
//s which is the day of the week
//k the number of days after s week day
function getDay(s, k){
var weekDays = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];
//variable index is the index in list weekDays of s
var index=weekDays.findIndex(function(weekDay){return weekDay==s;});
//use module operator % to get the remainder of the division (index+k)/7
//return the string value of the day
return weekDays[(index+k)%7];
}
The program is an illustration of functions.
Functions are used to group blocks of codes in order to perform as one
The JavaScript function, where comments are used to explain each line is as follows:
//This defines the function
function printDay(s, k){
//This initializes an array that holds the week days
var weekDays = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];
//This gets the index of day s from the weekDays array
var Sindex = weekDays.indexOf(s);
//This returns the day of the week k days after day s
return weekDays[(Sindex+k)%7];
}
Read more about similar programs at:
https://brainly.com/question/14101896