sleepCheck gives double output


We are doing the Introductions to Functions/Lesson 12, and have entered:

var sleepCheck = function(numHours)
if (numHours >=8)
console.log("You're getting plenty of sleep! Maybe even too much!");
console.log("Get some more shut eye!");

However, when we run it, it acts like it runs twice, because two iterations of the text appear (and the test fails). We can substitute a different value, and the correct text appears first, followed by the text using a value of 10. We can then erase the code entirely and run it, and one iteration of the text appears (using a value 10). We reload the screen, submit, and nothing appears, but then we paste the program back in, and the text appears twice again. It really acts as if there's a hidden call of sleepCheck(10) lurking behind the scenes.

We quit out and restarted the browser, with the same result. Is there a way to jump past this page if there seems to be a bug on the page itself?


hey hnmullin,
The problem here is with the instructions:

  • it says you should "return" the outcome which is within the function, you don't have to console.log it.
  • the exercise was to log 3 different sleepChecks in the console and you only wrote one
  • I don't know why you added console.log(numHours) to you code but if you change it to return it still seems to work fine

I hope this helped you :smile:


It did, thanks. :computer: