I cannot make the #12


#1



Hi, I can't proceed.. I don't understan my mistake, can anyone help me, please?


Apears this error:
SyntaxError: Unexpected token


// 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!";
}
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);


#2

On the else statement you put a semicolon after else and also put your bracket before the else instead of after the else. To make an else statement you don't open the squiggly brackets before the statement.. Your statement should look like this:

    } else {

#3

Or this worked for me:

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

console.log(sleepCheck(10));


#4

not working..
keep saying the same mistake :frowning:


#5

Hi this part you should remove the ;

var sleepCheck = function (numHours); <== this one 

if(numHours >= 8); <== this one too

and your else and if statement should have that strutture like that

if (condition) { //open the if statemnt 
   #do Something
} //close the if statetement
else  { //opene the else statement
    #do Something
} //close the else statement

then you should remove one } after the if statment because it close the sleepCheck function and put the else statement outside.

var sleepCheck = function (numHours){
     if(numHours >= 8) { // add one { here
         return"You're getting plenty of sleep! Maybe even too much!";
    }
{ //you should remove this { 
    else { //add one here too
        return"Get some more shut eye!";
    }//add on here too ofr closing the else statement 
}
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);

#6

Thank you so much, I finally made it!


#7

I dont get it, looking since 30 min.

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)

always get: SyntaxError: expected expression, got keyword 'if'


#8

Hi your if and else statement should be inside the function sleepCheck

var sleepCheck = function(numHours) { //open the sleepCheck function

/*here go your if and else statement */

} // close the sleepCheck function

#9

Thx for answer, it works, but why is the Hint constructed:

if (condition1) {
return "some string";
}
else {
return "another string";
}
It doesnt seems like they startet the curly bevore if, and also if i try to use 4 curlys, it doesnt work


#10

its because they only show you how the if and else statement should be .


#11

Thats the way it should be? But why it doesnt work then? Looked up on other sides they explain it the same way. Is this some tricky programmer logic or am i justed f***ed up? :smiley:

Tried also with other constructions/conditions/var but no way worked, can u give me an example when to use this way?


#12

SO your code look like that ?

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)

#13

AHA, it was nearly like that, i didnt used the first and last { }. Only the once after the if condition

Thx now it all make sense.


#14

thank you very very very much