Marwan Ahmed Marwan Ahmed - 5 months ago 50
Javascript Question

Unexpected token if (syntaxerror)

i don't know where the error is
it gives me unexpected token if
and i've done everything to solve it and still no hope:

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)

Answer

2 errors:
- function without {}
- sleepCheck written as sleepcheck (2 last calls)

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);

https://jsfiddle.net/hda3bxnr/1/