12. Functions & if / else


#1

Hi, So far for my code i have done the following:

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

This works fine and allows me to go to the next lesson, however, when i add:

console.log(sleepCheck(10));
console.log(sleepCheck(5));
console.log(sleepCheck(8));

the console comes up with the error:

"ReferenceError: numHours is not defined"

Can someone tell me why it is doing this as i would like it to appear in my console with the answers?!


#2

You change the name of the argument:

var sleepCheck = function (numHours) {
if (numberHours >= 8) {

It goes from 'numHours' to 'numberHours'.


#3

Thank you i was looking at it for ages!