Where is the semicolon that belongs after each alert statement? You have a run-on statement.
The next statement is not executed because the semicolon is missing. The interpreter thinks the statement is not over yet. It then finds it doesn't know what to do with the improper code it finds, and skips to the next semicolon.
Some interpreters incorrectly ignore missing semicolons when it is "obvious" that a new statement has been started. They should not do that. And you should never count on it happening.
MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
Javascript standards don't mandate semicolons but always make sure you put them because there are many browsers out there who would like to suck your project in.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733
That's a difference between Java and JavaScript.
Actually, there are certain places in JavaScript where semicolons are required (between statements), some places where they are optional (before a close brace), and some places where they are prohibited (before an else).
MidiMagic
Nearly a Senior Poster
3,319 posts since Jan 2007
Reputation Points: 730
Solved Threads: 182
> Actually, there are certain places in JavaScript where semicolons are required
Here you are talking about the syntax (for example the for loop) which mandates semicolon be placed. In Javascript as long as statements are separated by whitespaces (newlines) it shouldn't be a problem, though older / non-complaint browsers balk at it.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 733