Sleep Debt Calculator - Gets the correct answer, but undefined appears aswell?

Hello. when i run this code with console.log(calculateSleepDebt()); i get ;

1 hours too much sleep
undefined

Why does it print undefined ? i can’t find the reason for it.

Hello, welcome to the forum :slight_smile:

Take a look at the last line:

console.log(calculateSleepDebt()); 

This line is supposed to print out to the console result of the calculateSleepDebt() function call. But what is the result of this function? Are there any return statements inside this function?

4 Likes

ah now i see! i dont need the console.log(), i just need to call the function.
removed the console.log() and there we go :grin:
thanks for the help!

2 Likes

You’re very welcome :slight_smile:

1 Like