12. Functions and if/else. HELP PLEASE


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661#


SyntaxError: Unexpected token {
Oops, try again. There was a problem with your syntax.


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


#2

else means: everything else, which means you can't check any condition:

else {
  /* what else should execute */
}

#3

Thanks! (I also had to change if (sleepCheck >=8) to if (numHours >= 8)
:slight_smile:


#4

i haven't even seen that yet, good catch. I would indeed use the argument you pass into the function, and not the function name, like you discovered yourself :slight_smile: