I really don’t know what is the problem, but it says that “SyntaxError: Unexpected token {”
For curly brackets, and not sure what to do. I’ve been thinking “Have I needed to put it here or not?” and vice versa “Do I need to not put it here?”
Here is my code.
if (numHours === 10) {
return "You're getting plenty of sleep! Maybe even too much!";
}
else (numHours < 8) {
return "Get some more shut eye!";
}
};
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);```
If it is simple, I am really dumb. lmao
I have a problem, my following script doesn’t work.
var sleepCheck = function(numHours) {
if (numHours >= 8) {
return "You're gerring 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));
It says"
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.
I do the same way to often, stuck on a problem for so long and turns out to be a small spelling mistake. code academy is so strict on you saying exactly what it says it sucks
When it comes to output messages I’d almost agree with you. But on the other hand you need to keep in mind that a small typo in a variable name could change the whole sense of your code so being that strict is also what the language does not only what codecademy does. And btw making small and stupid errors is what almost everybody has to go through when learning to code
Hey,
Can someone review my code?
I’ve tried with out the strings in brackets, with the parameter as numhours and numHours, and without and with the console.logs on the function call, and without the semi-colons. Still, I’m not seeing my typo.
function sleepCheck(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));