12. Syntax Error


#1



I think I'm being really stupid but I can't work out what my syntax error is, it says its an unexpected token (

12.


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


#2

Depending on your background this might not look straightforward - What you're trying to do is define a function. This is achieved with the function keyword. var is mostly used for variables. Change your var into function :wink:


#3

Hi you should declare your function like that

var sleepCheck = function() {
 #here go your if  and else statement 
}

#4

Thanks, as soon as you said that it stuck out like a sore thumb! Nightmare! :slight_smile: