Functions 12/13


#1

This is what I got:

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);

The response to that is 'Oops, try again. There was a problem with your syntax.'
I really can't see where I'm going wrong here


#2

"greater than or equal to" is translated to an operator like this: >=


#3

Thank you! but I changed that and it's coming up with the same error


#4

here you need to use a semicolon instead of a colon.


#5

Thank youuu!!! that was such a silly mistake of mine


#6

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);
What is wrong


#7

you forgot the part with the sleepCheck function, maybe really forgot to copy and paste. Also it is >= not =>. As you would speak it >= greater than or equal to. Last guess would be a typo in the output messages but that is tedious to look for so maybe just copy and paste them from the instruction if you get one of these errors that the output is not what it is expected to be.


#8

i have the same problem and i try evrything and the idtor show me that i wrong


#9


#10

line 14.
please check the spelling of sleepCheck.


#11

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

I got an error with this...So what is wrong here?


#12

@viperkatz
On the if statement's condition you should not check if sleepCheck is greater than 8, you have to check if numHours is greater than 8 because sleepCheck is just the name of the function. You have to change your

to


#13


#14

i fixed it but still not work


#15

It is working.....
But, you have to return the exact sentence : "You're getting plenty of sleep! Maybe even too much!"
You have given too much space between "too" and "much!". Give just one space.


#16

Accept this as solution if it is working now please :wink::smile::smiley:


#17

thank you very much ,it is work :sweat_smile:


#18

// 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! Maybe even too much!";
}
else {
return "get some more shut eye!";
};
};
sleepCheck(10)
sleepCheck(5)
sleepCheck(8)

I'm not sure this doesn't work. Any clues?


#19

what is defining a function?


#20

@robobobo22, what's the error you're receiving? I'd say you need to delete the " ; " semi-colon off of your closing else statement:

else {
 return "get some more shut eye!";
} ; <-- Delete that
  ^