Build "Rock, Paper, Scissors"


#1

Function and if / else

Syntax Error: Expected ' { '


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


#2

Instead of the semi colon at the end add an opening bracket { and don't forget to close it after this line,

**}
}**


#3

Thanks for the help and I hope more people have the time to help me


#4

hi, i'm having problems
SyntaxError: Invalid or unexpected token

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

#5

Take a look at your quotation marks :slight_smile:


#6

still doesn't work lol

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

#7

You need to close the sleepCheck function. Your code was fine before except for the quotation marks. Can you spot the difference? :slight_smile:


#8

I still need help because it says syntax error: 'return' statement outside of function. plz help me.
i'll show you

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


#9

Now you have a sleepCheck function that doesn't execute anything because it is empty. The closing curly brace needs to come after the code that you want to execute each time you call it. Currently, the code you want in your function is outside of the sleepCheck function.


#10

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

you no need ( ) in return..
just
return "Get some..";
`


#11

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

//Try to check if it is correct.


#12

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