Seeking assistance with the "Days Of The Week Exercise" in JavaScript. I have searched MDN and made numerous attempts, but I am still unsure about what null represents and how to effectively use it.
If the argument (num) is less than 1 or greater than 7, the function is expected to return null.
const days = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
let returnDay = (num) => {
if (num >= 1 && num <= 7) {
return days[num - 1];
} else {
return null;
}
};
returnDay(1); // Monday
returnDay(7); // Sunday
returnDay(4); // Thursday
returnDay(0); // null