> What is wrong with my function - Javascript Code? (Beginner Coding)?

What is wrong with my function - Javascript Code? (Beginner Coding)?

Posted at: 2014-12-18 
Try:

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))

You need to get your placements of brackets and semicolons straight:

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));

The syntax is:

if (condition) command;

else command;

Instead of a single command you can have more of them; in that case there's a semicolon after each individual command, and they are enclosed in { and }

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))