Problem with Javascript Exercise 12 "Functions and If/Else"


#1

Javascript Exercise #12

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

Problem:
The code functions as it should - but I still get an error message saying that it's not functioning correctly. And this prevents me from moving to the next exercise.

Actual Output::"You're getting plenty of sleep! Maybe even too much!"

Error Message:
"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."

Code

// 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!";
    }
};

sleepCheck(10);

What am I doing wrong?


#2

The problem is here

You have a longer space between sleep! and Maybe.
Fix this so it would return:

return "You're getting plenty of sleep! Maybe even too much!";

#3

You're right! The problem is solved. Thank you!

Am I wrong in thinking that in "real life" the extra space wouldn't matter because the entire string is inside of quotes - I should be able to put as many spaces as I want.

But - when being reviewed by the automatic parsing used in this course, it flags as an error.

Mark


#4

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