Sleep Debt Calculator

Hi guys, So I got my code to run and it displays the result I expect. Except it adds an ‘undefined’ value under the result. I can’t locate what’s causing this, please I’m grateful for any help or input. I just want the ‘undefined’ gone. my code below.
https://gist.github.com/dc6a3813554166b34e7f723c51dc8ef2

The way you have built your calculateSleepDebt() function, when a particular condition is met it will print a string to the console, but nothing is actually being returned from the function. So when you are calling console.log(calculateSleepDebt()) what you are doing is running the function calculateSleepDebt(), which is printing the correct thing to the console, and then printing the return value from the function to the console, hence the undefined.
You either want to change all of the console.log() calls inside the function to return statements, or simply call calculateSleepDebt() instead of printing it to the console. Either way works.

1 Like

Thanks so much. So much clearer now.