Functions & if/else


#1


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

// it tells me "expected an identifier and instead saw "else" & "missing semicolon"


#2

take a good look at your curly brackets. after your if condition you have semi-colon, this should be a opening curly bracket

once you add this curly bracket, don't forget to close your function


#3

thanks!! helped a lot


#4

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