Functions & if / else - syntax error: unexpected token


#1

Hi there, please could you have a look at my code, I have no idea where it's wrong - I have changed console.log to return or just to formula and it also doesn't work. Also tried to change punctuation and still can't figure this out...

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

console.log (sleepCheck(10));
console.log (sleepCheck(5));
console.log (sleepCheck(8));


#2

you have to return this string too and add one more brace at the end


#3

Well spotted Rydan!!! its still doesn't fix it though...


#4

Fixed. It was { for if that was missing!


#5

looking at the code you provided you had that brace


#6

// 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 even too much!";
}
else {
return "Get some more shut eye!";
}

console.log (sleepCheck(10));
console.log (sleepCheck(5));
console.log (sleepCheck(8));


I have written this code over and over and still the system tells me I am having a syntax error that has an unexpected token. Any thoughts codecademy universe?


#7

you have to put an opening brace at the end not a semicolon