SleepDebt Calculator/ JavaScript functions

  1. you still get a undefined, as explained here:
  1. your last else if:
else if(actualSleepHours < idealSleepHours)

still misses its {}, yes, you can do without because its a single line. But is this ideal? Also, why not use else? if its not equal, and not more, it has to be less. So we could use:

else {
    console.log('You got minus ' + (idealSleepHours - actualSleepHours) + ' hours of sleep. That is not enough and you need more sleep, take a rest !!');
}

now else doesn’t have a condition, and everything is fine

Yor’re right ! I fixed this. Now I have to find out where to put the return into the calculateSleepDebt function.

why would you do that? we are not interested in the value returned by the function, so undefined is fine. We simple do not want to log the returned value to the console

^ you really have to read my answers careful.

Sorry stetim94 :).

Thanks for helping me and giving me more than one advice !!
I will do better next time ^^

Best Mike

no worries, here to help :slight_smile:

just make sure you take time to grasp everything

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.