12. Functions & if/else - where am I going wrong?


#1



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

I can't seem to get this right. I either have an unexpected token, wrong syntax, or it thinks I'm using the wrong comparative operator. I've looked at other answers but I just can't seem to figure out what I'm doing wrong.


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

@javaslayer58091

See amendments I have made above :slight_smile:


#3

I tried this and thankfully the desired results appeared - however, it still reads at the bottom "Oops, try again. It looks like sleepCheck() isn't returning "You're getting plenty of sleep! Maybe even too much!" when numHours is 10. Check your if / else syntax and whether you're using the correct comparison operator."


#4

Copy and paste this sentence from the instructions, this exercise is really picky about punctuation/spacing/grammar.


#5

Thanks! I have a habit of putting 2 spaces between sentences. Deleting one between "sleep" and "Maybe" solved it :smiley: