My Syntax is messed up


#1


Javascript Lesson 12: Functions & If/else

My syntax is not correct but I'm not sure where I'm going wrong.


// 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 (numHours < 8) {
    return "Get some more shut eye!";
};
var condition1 = sleepCheck(10);
    console.log (condition1);
    
var condition2 = sleepCheck(5);
    console.log (condition2);

var condition3 = sleepCheck(8);
    console.log (condition3);
    
}


#2

Hi this line remove the ;

var sleepCheck = function (numHours); <--

them you should put that

var condition1 = sleepCheck(10);
    console.log (condition1);
    
var condition2 = sleepCheck(5);
    console.log (condition2);

var condition3 = sleepCheck(8);
    console.log (condition3);

outisde the function sleepCheck()


#3

Is this what you mean?

// Write your function below.
// Don't forget to call your function!
var sleepCheck = function (numHours)

var condition1 = sleepCheck(10);
console.log (condition1);

var condition2 = sleepCheck(5);
console.log (condition2);

var condition3 = sleepCheck(8);
console.log (condition3);

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


#4

no I mean like that

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

#here put the if and else statement

}#close the function

#here outisde the function put the all the variable condition(s)

then

the else statement doesn't take any condition

if (condtion) {
    #do something
}
else {
    #do something
}

also here remove the ; at the closing } of the if statement

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

#5

If u don't have the answer yet it's

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 hope that helps