I need help with this lesson on Javascript functions


#1


Intro to functions in JavaScript, Lesson 12


I have some issues with this code. Whenever I submit this code into the system it returns "[Function: sleepCheck]" which is in no way what I intend to do. For some odd reason the codecademy system says I am doing it right and passes me to the next lesson. Please help me figure out why this wont work.


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


#2

Note the parameter in the above. numHours. That is the variable to use in the function.

The (6) should be removed from the condition above, and tacked onto the function call...

numHours > 8

sleepCheck(5)

#3

Return don't put "()"

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

This is bad
return("Get some more shut eye!");

https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Sentencias/return


#4

I did that and still does not seem to work. can you give me an example of the full code so I may see how the entire code should look.


#5

Show us your corrected code, please. Thanks.


#6

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