WAS
WAS

Reputation: 59

SyntaxError: missing ; before statement on normal statement

I'm not sure why I am getting this code. Basically I want to be able to position my emitter dynamically but when I add a option to check for position and correct as need be I keep getting this error.

The code added is

                    if ( pos == 'right' ) {
                      xcord = width + xcord;
                      console.log("xcord");
                    } elseif ( pos == 'center' ) {
                      xcord = width / 2 + xcord;
                    }  

Which if removed will not cause an error, but with it, throws the missing ; statement.

Note I have tried this with shorthand var operators as well, still same error.

http://codepen.io/WAS/pen/Ejgsw

Upvotes: 0

Views: 76

Answers (1)

Pointy
Pointy

Reputation: 413712

It's because there's no elseif keyword in JavaScript.

It's else if, two words.

Upvotes: 4

Related Questions