12 one


#1

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

when numHours = 10 it is not printing you'r getting plenty of sleep. plz help me how to do it
thank you in advance


#2

@ranjangc You forget the "()" at the return statement. The Code SHould look like this:

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


#3

No the () around return statements are actually not necessary. Not harmful, but not necessary either.
@ranjangc the syntax seems to be ok so probably there is a typo in the error message e.g. the extra space between much and !, idk just copy and paste them from the instruction.


#4

Thank you its for extra space


#5

I thought there has to be a semicolon after every line in the bars.
}; Does line 4 have to have one?


#6

no after conditions might be problematic but after assignments or function calls should be a semicolon e.g.

var name = value;
console.log(value);

#7

thank you helped me alot


#8

what is wrong with this code?

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


#9

else is the default case and therefor it has no condition.


#10

hi! what's wrong with this?

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


#11
return "You're gettig plenty of sleep! Maybe even too much!";
                    ^

The console is expecting an exact argument. You can't have any mistakes in your return statements (Including spelling errors). just fix "gettig" to "getting".


#12

oh yes! I've just fixed it. thank you so much :wink:


#13

Also missing semi colon after the functions closing bracket.