Here is the code above. On running it in console, an extra ‘undefined’ string below the actual log appears. There is something wrong, but I can’t figure out. Help me, please.
Hello! This is due to the fact there are no return
statements in the calculateSleepDebt
function. When you log this function at the end, it is called-so all of the console.log()
s are printed, and, since there is no return
, the default return
value from a function is undefined
, so that is what you are printing when you do console.log(calculateSleepDebt(9))
.
I hope this helps!
2 Likes
Thanks for the help I got it.
1 Like