Can somebody help with this 12. Functions if/else


#1



opps, Try again. There was a problem with your syntax.
syntaxError: Unexpected identifier


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


#2

if(numHours >= 8); //remove ; add a opening {
        return "You're getting plenty of sleep! Maybe to much!";
    }; //remove ; from here

also you didnt close the function

and

else {
        return "Get some more shut eye!";
    
    }; // unnecessary semicolon

#3

Yes I remove all the semicolons. It was just to see if it worked or not . my function should be open at the top line and closed before the else Now I'm still getting a syntax error.


#4

Ok I got it. Thanks for the help. But what I don't understand is why is it opened on the second line as well as the first. Maybe I missed something in the middle of learning.


#5

no,your if else should be inside of function.

what did you open at the second line as well as the first?

var sleepCheck = function(numHours) { //opening function
    if(numHours >= 8){ // opening if
        return "You're getting plenty of sleep! Maybe to much!";
    }//closed if
    else { //opening else
        return "Get some more shut eye!";
    
    }//closed else
}//closed function

#6

OK. Got it thanks for the help.


#7

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