Help needed! Can someone assist me in resolving the issue where the word 'undefined' is being displayed in the console? I'm a beginner in programming and struggling with this.
Here's what I'm currently seeing:
You are not getting enough sleep undefined
Code snippet that needs fixing:
function getSleepHours(day) {
if (day === 'monday') {
return 8;
} else if (day === 'tuesday') {
return 8;
} else if (day === 'wednesday') {
return 8;
} else if (day === 'thursday') {
return 8;
} else if (day === 'friday') {
return 8;
} else if (day === 'saturday') {
return 8;
} else if (day === 'sunday') {
return 5;
}
}
const getActualSleepHours = () =>
getSleepHours('monday') +
getSleepHours('tuesday') +
getSleepHours('wednesday') +
getSleepHours('thursday') +
getSleepHours('friday') +
getSleepHours('saturday') +
getSleepHours('sunday');
const idealSleepHours = 56;
let let2 = getActualSleepHours();
function calculateSleepDebt() {
if (let2 >= idealSleepHours) {
console.log('You are getting sound sleep');
} else {
console.log('You are not getting enough sleep');
}
}
console.log(calculateSleepDebt()