Funtions and if/else


#1

hi fellow coders i need some assistance with regards to lesson 12 functions and if/else here is my code
''' var sleepCheck=function (numHours) if (sleepCheck>=8) {return "You're getting plenty of sleep! Maybe even too much!";} else{ return "Get some more shuteye!";};
sleepCheck(10);
sleepChek(5);
sleepCheck(8);'''


#2

You need you use your argument in the if-condition, not the function.


#3

it´s not working for me though

var sleepCheck = function(numHours) {

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

};

sleepCheck(10);
sleepCheck(5);
sleepCheck(8);


#4

Hi here
You wrote

"You´re getting plenty of sleep! Maybe too much!";

Instead

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

You put ´ instead of ' between You and re


#5

Thanks, damn typos :smiley:


#6

Thanks for the help guys it worked


#7

Here's my code:
var sleepCheck = function(numHours) {
if (numHours >=8) {
return "You're getting plenty of sleep! Maybe even too much!";
}
else {
return "Get some more shuteye!";
}
};
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);

This returns:
You're getting too much sleep! Maybe even too much!

And an error message:
function doesn't return "Get some more shuteye!" when numHours is 5


#8

Never mind. I just saw that I wrote shuteye instead of shut eye.


#9

Why doesn't this code print out results for all three of the sleepCheck function calls.


#10

Hi try to put your call function inside console.log()

console.log(sleepCheck(10))
....