12/13 Critique my code?


var sleepcheck = function(numHours)
if(numHours >= 3)
{return ("You're getting plenty of sleep! Maybe even too much!");}
{return ("Get some more shut eye!");}

A error message pops up saying "StynaxError: Unexpected token if"
Any help is appreciated


You need to wrap your function in {}


{var sleepcheck = function(numHours)}



Hey, You didn't use the correct syntax for your function.

Here is the correct Syntax

var functionName = function(parameters) {
    // Your code goes here;

So, according to the Syntax above, your function should look like this

var sleepcheck = function(numHours) {
    if (numHours >= 3) {
        return ("You're getting plenty of sleep! Maybe even too much!"); 
    } else {
            return ("Get some more shut eye!");

Check the working script I gave you and verify your mistakes, also try to make your code look good so it is easy to understand, :smiley:


Thank you for your help!


@heyyoushutup Welcome Even I am learning JS :smile:


Thanks for completing my answer. Just some remarks, I guess its numHours >= 8 and you don't need the () around the stuff after return (it's not a function just a keyword).


Yes i have seen that. Forgot to tell ya xD