Wrong Code? Why?


#1


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


The exercise asks for the code to print the dialog when the condition is met. When I enter the parameter, the dialog does not print. This is because I am using return in the code and not the console.log. Why is the exercise asking me to enter the code wrong? When I do it the way it wants, I get the number entered instead of the dialog.


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(10);.


#2

two things, first:

a function only calls when executed, you never call the function, so the function never executes

return is perfectly fine? To log what the function returns do console.log(functionCall()), where functionCall() is the actual function call


#3

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