Sleep Debt Calculator

Hi all - apologies if a similar question has been posted here previously. Just wanted to ask if anybody can see where I might have gone wrong with the sleep debt calculator?

It all seems to run fine but whatever numbers I use for getActualSleepHours, whenever I start the program by calling the calculateSleepDebt() function, it only returns:

if (actualSleepHours = idealSleepHours) {

console.log('You had the perfect amount of sleep!');

The two numbers clearly do not add up however, so I’m not sure why this is the only line that is logged.

Any help appreciated.

By the way, this is my first time posting here, so apologies if I haven’t included enough information/links

On line 37 you have written this

if (actualSleepHours = idealSleepHours) {

And this is reassigning actualSleepHours to idealSleepHours, thus always returning the phrase inside that block. You need to use either ==or === for it to work!

Ah yes, excellent - thanks very much. Knew it would be something obvious like that!

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