Crashes Every Time I go to Submit


#1


https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661


Nothing is behaving incorrectly, or atleast I dont think so since its just freezing every time I hit submit.


// Write your function below. 
// Don't forget to call your function!
var sleepCheck = function(numHours) {
    if(numHours >= 8)
    console.log("You're getting plenty of sleep! Maybe even too much!");
    else
    console.log("Get some more shut eye!");
    sleepCheck(10);
}


#2

HI you should put this line

sleepCheck(10);

Outside the sleepCheck function then change all the console.logs with return


#3

This worked, I just wish I understood why.


#4

It's because of this line

sleepCheck(10);

it's the function call so you can't put it inside itself (There are some case that you can do it) but this isn't one of it.

var sleepCheck = function(numHours) {
   #here your code
}

#call the function sleepCheck here
sleepCheck(10);

#5

Ok thank you, I understand now :heart_eyes:


#6

Did you mean to write, function call?


#7

...........Yes I do .....


#8

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