Extra Equals Sign in #12, Introduction to Functions in JS?


This is my first post, sorry if I format a a bit weirdly!

I'm stuck on problem #12 in "Introductions to Functions in JS".

And I keep getting the following error message:

SyntaxError: Unexpected token =

My code is:

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

I'm assuming the error message means that I've added an equals sign (=) where I shouldn't have. Is that right?

Thank you with the help!

  1. To check is something is greater than or equal to you use >= not >==

  2. after your condition if (numHours >== 8); you shouldn't have a semi colon

  3. When closing your if statement you should just have } without a semi colon

Conclusion should look like this:

if(numHours  >=  8) {
  return("You're getting plenty of sleep! Maybe even too much!");


Yay! I was right about at least one thing! :slight_smile:

I don't completely understand when to put semi colons. I know they're supposed to be like "periods" and places so stop for the computer, but I know I'm using them wrong sometimes.

Thanks for the help!


Lucky for you Codecademy has an article on this -Click here to read

another post


What I'm getting from the Codecademy article is that you usually use semicolons when:

  • When two statements are on the same line like in

if(numHours === 6) { return ("Yay!"); console.log("Wahoo!")


And you don't use it when:

  • After a closing curly bracket {}
  • After round brackets () for and if, while, for, and switch statement.

Is that all I need to know? And thanks for the article and thorough answers.


Yip, I think that's all, as you go along you will get the hang of it...

You also need a semi colon for console.log

//few examples for ;
var something = "something else";
return "something";

//no semi colon
if ("hi" > 2) { //no semi colon

} //no semi colon


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