12 Function if/elce


#1

Hi!, i don't understand what is wrong with my coding, thanks

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!";
}
}
var sleepResult=sleepCheck(10);
console.log(sleepResult);
var sleepResult=sleepCheck(5);
console.log(sleepResult);
var sleepResult=sleepCheck(8);
console.log(sleepResult);


#2

It depends on what the instructions want you to do. Your code does function correctly on https://repl.it.


#3

This is the actual way to call if and else statement within a function .by Chaudary waqar
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!";
}
};

console.log(sleepCheck(10));
console.log(sleepCheck(5));
console.log(sleepCheck(8));


#4

Hallo there... What is wrong with this code.

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 sleep much!";
}
else {
return "Get some more shut eye!;
}
};
console.log(sleepCheck(10));
console.log(sleepCheck(5));
console.log(sleepCheck(8));


#5

Make sure to use the exact text strings provided in the instructions. Remember to always use quotation marks at the beginning and end of text strings. Lastly, please start a new topic whenever you have questions :slight_smile:


#6

Thanks for your reply. Appreciated.


#7

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