Lesson 12 Syntax error Unexpected EOF?


#1

I cannot find what is wrong with this code but it will not run.

var sleepCheck = function(numHours){
if(sleep>= 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

2 points:

  1. at your IF statement, change "sleep" to "numHours"
    OR change "numHours" in function() to "sleep"
    either way is okay.
    What parameter you have in function declaration should match the one in function definition.

  2. add closing " on "You're getting...".
    it is a string, make sure you open and close a string.


#3

I have aslo a problem with this lesson!
this is what i am writing and am getting this respond
Oops, try again. It looks like sleepCheck() isn't returning "You're getting plenty of sleep! Maybe even too much!" when numHours is 10. Check your if / else syntax and whether you're using the correct comparison operator.
what am i missing?

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(8));
console.log(sleepCheck(5));


#4

You are missing a semicolon for your sleepCheck function


#5

where exactly do you mean ?


#6

after very last of your closing curly bracket.
http://inimino.org/~inimino/blog/javascript_semicolons. Check this link out, if want to know more about semicolons


#7

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