Write a function that accepts a weekday as a string (e.g. ‘Sunday’) and returns the number of days to the
next specified weekday. The input should be case-insensitive. If the specified weekday is today, return Hey, today is ${ specifiedWeekday } =)
, otherwise return It's ${ number } day(s) left till ${ specifiedWeekday }
.
Please note, although input is case-insensitive, weekday name in the output string should be always in proper
case.
howFarIs(‘friday’); // “It’s 1 day(s) left till Friday.” (on October 22nd)
howFarIs(‘Thursday’); // “Hey, today is Thursday =)” (on October 22nd)
Thats what I
we done, pls help me with the next steps or with the correct solution.
function howFarIs(day) {
let test = new RegExp(`${day}`, 'gi')
for (let day of days) {
if (day.match(test)) {
var dayIndex = days.indexOf(day);
}
}
let date = new Date();
let todayIndex = date.getDay()
}