Introduction to functions in JS Part 12


#1

Hi
From
https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/4?curriculum_id=506324b3a7dffd00020bf661#

This is my code:

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));
console.log (sleepCheck (5));
console.log (sleepCheck (8);

The error message is:
SyntaxError: Unexpected token else

What have I done wrong?


#2

console.log (sleepCheck (10));
console.log (sleepCheck (5));
console.log (sleepCheck (8);

Take out all of this and add
sleepCheck(10);


#3

@favershamgirl1978,
You are using the semi-colon's-; like candy.....

For Javascript a semi-colon-; is an End-of-Statement indicator

An IF ELSE statement should look like

if (condition) {
   //your code
}
else {
   //your code
}

As you can see NO semicolon's used.....