Sleep Debt Calculator


I’m trying to go through the Sleep Debt Calculator project and I keep getting this error that I have not defined my variables, at least that’s how I understand it. I followed the hints and even the video and I still keep getting this error. I can’t understand what I did wrong.

Here’s the code and the error: (I tried copying but I ended up with an error that I can’t upload more than 2 links since I 'm a new user)

According to you, where did you define the idealSleepHours variable?

that would be inside the function, I gave it the value of the getIdealSleepHours function.
Do I have to define variables separately, outside of a function?

1 Like

That depends on what you achieve to accomplish. But you are going in the right direction. Do you remember learning about scope (rules)?

No, to be honest I don’t. I tried searching too but to no avail.

The scope lesson is after the free-form project, here it is:

can you access that? I would recommend doing scope lesson first before doing the sleep debt project


I can access it, yes. I 'll try solving that first. if that doesn’t help I’ll ask again, thank you!

I figured it out! It was the next chapter in my learning curve that’s why I hadn’t take it, yet.

Apparently, I had to write my logs and ifs inside the function. Thanks again, I greatly appreciate that you didn’t give a straight answer, rather, I had to find out for my self, just from a different path.


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