I have two arrays which starts off as this:
let days = [null, null, null, null, null, null, null];
const weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
Depending on what data I'm given, I want to map a new array with the corresponding weekday, but still keep it the same size array.
let numDays = ["0","2","4"]
let days = days.map(?)
days
> ['Sunday', null, 'Tuesday', null, 'Thursday', null, null]
I have attempted a conversion function which can convert numDays to its correspondingweekdays
const convert = function (c) {
return weekdays[c];
}
numDays.map(convert)
> ['Sunday', 'Tuesday', 'Thursday']
But not sure how to retain the array size for the result I need.
Cheers!