SleepDebtCalculator help

const getSleepHours = day =>{

switch(day) {

case ‘monday’:

return 8

break;

case ‘tuesday’:

return 7

break;

case ’ wednsday’:

return 7

break;

case ‘thursday’:

return 6

break;

case ‘friday’:

return 6

break;

case ‘saturday’:

return 7

break;

case ‘sunday’:

return 8

break;

default:

return ‘Error!’

}

};

const getActualSleepHours = () =>

getSleepHours(‘monday’) +

getSleepHours(‘tuesday’) +

getSleepHours(‘wednsday’) +

getSleepHours(‘thursday’) +

getSleepHours(‘friday’) +

getSleepHours(‘saturday’) +

getSleepHours(‘sunday’);

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

console.log(getActualSleepHours());

i keep on getting an error when testing getActualSleepHours, the error is 15Error!6678

you could add a log to see what day is wrong:

default:
   console.log(day);
   return 'Error!';

you made a typo here:

case 'wednsday':

Cheers! thanks :slight_smile: sorry that i made a topic for a dumb typo ^^

May i ask how this log actually works?

The .log() serves a debug purpose here to show us which day has a typo in one the cases

1 Like