12. Fuctions & if/else


#1

Hi need help

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


#2

HI
see my comment

// 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!"
    }; // why is here a semicolon? 
    else{
        return "Get some more shut eye!";
    };

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

#3

@dookoo_de ok thanks I know what I did wrong now.


#4

that is actually wrong it is
// Write your function below.
// Don't forget to call your function!
var sleepCheck = function (numHours) {
if (sleepCheck >= 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);


#5

What is wrong?
The semicolon is really a problem as I pointed out here:


#6

So guys this is worked the problem was there were 3 pairs of curly brackets open and only 5 curly brackets in total.. (for the answer of dookoo_de

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


#7

Your code dont wanna run like you want.

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

you get with your function the parameter numHours but in your if statement you compare sleepCheck what truly is a function.