Need help with Intro to functions in JS*** Lesson12 functions and if/else***


#1


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


SyntaxError: Unexpected token if


// 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 somoe more shut eye!";
};

sleepCheck(10)


#2

Hi joeboulos!

Your code is not so bad, it only has two small errors. First, on line 3, the key that starts your function is missing. On line 6 you should delete the semi-colon before the "else" condition. And finally on line 7 there is an orthographic error in the word "somoe" that does not comply with the assigned instructions.

Your code might look like this:

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)

I hope I was of help, good luck!


#3

ah, forgot those curly brackets, ty for the help


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.