Help! i dont understand! What an doing wrong pls help im stuck in this exercise!


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.

function sleepCheck(numHours) {
    if (sleepCheck >= '8')
console.log('You are getting plenty of sleep! Maybe even too much!');

else if (sleepCheck < '8') 
console.log('Get some more shut eye');



copy and paste the exact text from the instructions for the console log statements. its really picky like that.


Functions & if / else
An especially useful application of reusable code is if/else statements. These can be very wordy, and a pain to type repeatedly.

We are going to write a function that checks how many hours of sleep a night you're getting. Inside the function will be an if/else statement. We want the function to check many different numbers of hours to see whether a person is getting enough sleep.

Write a function named sleepCheck that takes the parameter numHours
Inside the function, write an if statement where if the number of hours of sleep is greater than or equal to 8, the computer will return "You're getting plenty of sleep! Maybe even too much!";.
Otherwise (else) if the number of hours of sleep is less than 8, have the computer return "Get some more shut eye!";
Then call the function with different hours of sleep

Call the function with 10 hours of sleep, like this: sleepCheck(10);
Call the function with 5 hours of sleep.
Call the function with 8 hours of sleep.


also you forgot the Curly Braces for the if and else if statements { }


oh hahahhaha ok no. I meant copy and paste the text
"You're getting plenty of sleep! Maybe even too much!" and put it inside of your console.log() and you also might need to use return but I'm not sure

sorry for the miscommunication there :laughing:


but isnt it already in my console.log?


its not the exact text they are checking for. there are a lot of times where you have to have the exact same answer that they do. with yours you have You are instead of You're like they do. its really annoying but it happens a lot.

I suggest just copying and pasting the text all the time. its faster and fixes that problem


but when i do the thing with the curly brackets it say "SyntaxError: Unexpected token if"


but u helped me alot! Thanks man! Im stuck in this exercise since 3 days and i didnt realize i made that kind of mistake!


can you send me a link to the lesson? and your updated code?

no problem, sometimes it just takes someone else looking at the code to figure out what needs to be fixed :smile:


theren you go


can you send the code that you have now?


i thought its already in there but:

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



so one thing that needs to change is if(sleepcheck >= 8) and the else statement. sleepCheck should be numHours. also that else statement needs to be an else if.

you also need to change the numbers is the if and else if statements to be numbers and not strings. you have '8', but it needs to be 8.

copy and paste for this text just like the first one.

add some more curly braces for the function and you should be fine.

tell me if it still doesn't work because I have the working code :smile:


can u please send the working one it still says "unexpected token: if" i want to compare urs and mine and i have three more questions: when did u start coding and do u have a job where you need to know how to code? and the last one: do you think you can actually learn code with codeacademy? (without paying monthly) Thx :wink:


I want to make sure you understand what going on so I wont send the finished code yet. although if you send what you have now ill gladly figure it out with you.


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


and what about my questions


but im gonna stop coding for today its 10 pm in germany u can text me whats wrong with the code above and ill write you as soon as i come back to code
have a good evening and thx for the help again :wink:


just add these curly braces. the syntax for the function you are making is like this

function myFunction() {


and an if statement is this
if() {

remember that else if and if has () but else doesn't

if() {

}else if() {


this is because the else is like when none of the options are correct. so usually in the else spot you have something like "please use this answer instead"


no problem :cake: anytime you have questions feel free to ask the forums. or if you see that I'm online you can ask me personally, I don't mind. goodnight :full_moon_with_face: