Can someone tell me where I went wrong?


// Write your function below.
// Don't forget to call your function!

var sleepCheck = function(numHours) {
return numHours >= 8;

if (sleepCheck) {
console.log ("You're getting plenty of sleep! Maybe even too much!");
else {
console.log ("Get some more shut eye!");




i think you need to put a condition in the if statement, someting like: if (sleepCheck > 6)


I'm not too sure about that as I get a result, it just doesn't change when I put other values when I call my function...


Everything works expect I get a true reading instead of 8


the reason for that is that you ask in youre if statement if there is a sleepCheck value, and there is so he prints oud the sentence. if you change the condition so that it isn't always true, the answer will change.
(sorry for bad english)


Your if/else statement needs to be part of your sleepCheck function. So when you pass a number into sleepCheck, code will execute depending on the if condition.

For example:

var five = function (number) {
if (number = 5){
console.log("the number is 5");
} else {
console.log("the number is not 5");


What code will execute?



I tried running it like thing:
var sleepCheck = function(numHours) {

if (numHours >=8){
console.log("You're getting plenty of sleep! Maybe even too much!");
else {
console.log("Get some more shut eye!");

Still gives me an error but now I see what you are trying to do, I just can't get it right... Sorry day 3 of Javascript coding still a noob


You're doing fine. What's the error message?



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.

it says "get some more shut eye" twice...

and the amount of hours is 10 which means it should say "getting plenty of sleep"


@biff75 dont worry I got it thank you very much for the help


Glad to see you worked it out :slight_smile:


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