Sleep Check - Need help!


#1

I'm having trouble getting my code to work. Can anyone help please? I don't understand what part I need to correct. I don't know if maybe I have one too many curly brackets??

// 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!";
};
console.log(sleepCheck(10));
}


#2

Wrong category!* This should be posted in Javascript :slight_smile:


I think you've added too many curly brackets! It's hard to tell when the code isn't formatted well. But the flaws I see in your code are:
* It looks like your fingers had a spasm inside the if's condition :stuck_out_tongue_closed_eyes:, you don't need "& g t;"
* You don't need a semicolon after return


That's all I see. Also, next time try adding three backticks (`) before and after your code so you can keep the formatting and it's also easier to read.


*edit: this was now moved to the right category


#3

Thank you! Looks like you were right! :slight_smile:


#4

// 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!";
}
};
console.log(sleepCheck(10));

and also getting output : you're getting plenty of sleep! Maybe even too much!
but
nolt able to continue..error it like this
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.