Maximum call stack intro to functions


#1

What is wrong with this code?

var sleepCheck = function (numHours) {
if (sleepCheck() >= 8) {
return "You're getting plenty of sleep! Maybe even too much!";
}
else {
return "Get some more shut eye!";
}
};
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);


#2

if (sleepCheck() >= 8) { .. }

You called function inside the function. You need compare here parameter numHours with 8.


#3

Denys is right, you did call the function inside the function.

Line #2 should be:

if (numHours >= 8) {