Java script sleep debt caculator

My code seems fine but I keep getting an error can anyone help me?
const getSleepHours = day => {
switch(day) {
case ‘monday’:
return 7
break;
case ‘tuesday’:
return 5
break;
case ‘wednesday’:
return 9
break;
case ‘thrusday’:
return 8
break;
case ‘friday’:
return 8
break;
case ‘saturday’:
return 10;
break;
case ‘sunday’:
return 4
break;

default:
return ‘Error’
}
};

const getActualSleepHours = () =>
getSleepHours(‘monday’)+
getSleepHours(‘tuesday’)+
getSleepHours(‘wednesday’)+
getSleepHours(‘thursday’)+
getSleepHours(‘friday’)+
getSleepHours(‘saturday’)+
getSleepHours(‘sunday’);

console.log(getSleepHours(‘monday’));
console.log(getActualSleepHours());

Hello, and welcome to the forums!

Right now you’re testing monday at the bottom. Try testing ‘thursday’ instead.
console.log(getSleepHours('thursday'));

This will show Error in the console.

Try to figure out why that particular day is producing an error. Once you figure that out, then the rest of your code will work as expected.

Click here if you still need more information

Your getSleepHours function has a typo for thursday, so when your other function tries to get the hours for that day using the correct spelling, it ends up getting sent Error instead.

2 Likes

You rock! thank you so much. I will try and keep a better eye out for spelling mistakes.

2 Likes