12.Functions & if / else


#1

/ Write your function below.
// Don't forget to call your function!
var sleepCheck = function(numHours){
if(numHours>=8){
return "You're getting plenty of sleep! May be even too much!";
}
else
{
return "Get some more shut eye!";
}
};
sleepCheck(5);


#2

Seems like it is more of a typo than an error:

"You're getting plenty of sleep! May be even too much!" // your output
"You're getting plenty of sleep! Maybe even too much!" // expected output

The problem is probably:

May be
Maybe

#3

ya it worked thanks ....

its a string right it can have many spaces why it is showing as a error


#4

The test function compares your string against an expected string and if they match you can pass and there a space makes a difference. But you're right this is not a syntax error or something that javaScript raises itself but an error that the author raised because the code is not correct according to the instructions.


#5

help!!
what's wrong with 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 shut eye!";
}

sleepCheck(10)


#6

line 3 of your code, right at the end of the line - there's a missing speech mark ( " ).


#7

Where em I wrong? Thank you for helping
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";
}
};
sleepCheck (10);
sleepCheck (5);
sleepCheck (8);


#8

Dans Else il manque un point d'exclamation à la fin de votre phrase qui est "return".
Simple erreur d'ecriture qui bloque la comparaison de l'exercice par le programme...


#9

it is not working for me. enter the same code and still received the error "
Oops, try again.
It looks like sleepCheck() isn't returning "You're getting plenty of
sleep! Maybe even too much!" when numHours is 10. Check your if / else
syntax and whether you're using the correct comparison operator.
"