This code is not returning "Get some more shut eye!"


#1

Hi there,

Could you help me with this? I have been stuck for hours. This code is not returning "Get some more shut eye!" but it does return the first two sentences of the code. Let me know what I am doing incorrectly. I would greatly appreciate it.

var sleepCheck = function(numHours) {

return numHours ;

};
if ("numHours >= 8") {
console.log ("You're getting plenty of sleep! Maybe even too much!");
} else {

console.log ("Get some shut eye!");
}
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);


12. function and if else
#2

You closed your function to early. The if/else should be alsp part of the function. Also "numHours >= 8" is a string/a word if you want that it does check if numHours >= 8 then you need to get rid of the "".


#3

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

also try return"You're getting plenty of sleep! Maybe even too much!"
return"Get some shut eye!"


#4

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