12 Funtions if/else


#1

Would someone mind looking at this code. I have been stumped on it all day and get the following error;

SyntaxError: expected expression, got keyword ‘if’

This is my code:
var sleepCheck = function (numHours)
    if (numHours >= 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

you forgot the closing } for your function or your better for your else depending on how you’re looking at it.


split this topic #3

5 posts were split to a new topic: Oops, try again. It looks like sleepCheck() isn’t returning “You’re getting plenty of sleep! Maybe even too much!” when numHours is 10


Oops, try again. It looks like sleepCheck() isn't returning "You're getting plenty of sleep! Maybe even too much!" when numHours is 10
#7

I do not know what’s wrong with the following script:
// Write your function below.
// Don’t forget to call your function!
var sleepCheck = function(numHours) {

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

    sleepCheck(5);

    sleepCheck(8);

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

See if you can’t figure out the issue in this area here.


#9

Thanks so much, it has been done.