Introduction to Functions in JS Functions & if / else


#1

var sleepCheck = function (numHours) {
sleepCheck(10)
};
if (numHours >= 8) {
return "You're getting plenty of sleep! Maybe even too much!";
}
else {
return "Get some more shut eye!";
}
plzzz help with this it says it is a illegal return statement


#2

You can't use return outside the function. There are many problems here. First:

var sleepCheck = function (numHours) {
    sleepCheck(10)
};

Has absolutely no purpose, and will give you 100 different errors. You cannot call a function inside the same undefined function. Also you forgot an ending semicolon.

Next:

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

You cannot return outside of your function.

You need to insert your logic (if/else) into your function, and then call it after it's defined.


#3

i dont understand what u mean