I need to return a string of all matched days in a function, but Im not understanding a basic principle that I need to do this correctly. I want to map the day number to a day IE "0" = "Monday" (in this case just M-F); I believe .map is what I want, but I don't understand it enough.
function dayOfWeek(dayIndex) {
return ["Monday","Tuesday","Wednesday","Thursday","Friday"][dayIndex] || '';
}
const days = [1,2,3,4,5];
console.log(dayOfWeek(days));
returns only "Monday", the first day. I would like it to return "Monday, Tuesday, Wednesday, Thursday, Friday"