Learn JavaScript SleepDebtCalculator Syntax Issue (need another pair of eyes hehe)

Hey there!

I am looking for someone who can double check to see if I made a mistake in my code, related to the if/else statements. In this particular line of code which I have attached below. If you can let me know what you notice, and offer some advice please send me a reply!

Here is a screenshot of the assignment:

Thank yous!
-Bello

Are you sure you linked the right screenshot? Doesn’t seem related to your question.

What makes you think there is a mistake? Could you explain the problem you’re encountering?

OOOPPPS I Mean this:

Your else block is odd. In a weird syntax you smuggled a condition in. Either you have an else block – without a condition – or an else if(condition){} block as you do above (‘the lazy bum’) ;-)
remove the condition block (actualSleepHours < idealSleepHours) and the superfluous curly braces in that last block.

2 Likes

Thanks for the response I see the error now… However now I have this issue XD

actualSleepHours and idealSleepHours are defined within the function calculateSleepDept and not available outside that function’s scope.
Either you move all the logic below that function into the function and call calculateSleepDept and the bottom or you move actualSleepHours and idealSleepHours out of the function and then remove calculateSleepDept entirely.

2 Likes

Pawfect! Thanks! I will implement this as soon as I get a chance!