JavaScript is NOT Java, so there are important differences.

Its syntax, however, looks similar enough to learn it more easily if you know Java.

JavaScript can be used in HTML and is then run by a browser's script engine, provided that support hasn't been switched off by the user.

Script can be contained in the 'head' tag, ...

in this case just three variables, ...

but it can also be contained in the body, to generate HTML by using 'document', one of JavaScript's objects, and its 'write' method.

What's remarkable is, that you don't specify data types ( like 'int' ), as is required in Java. Variable names can be as long as you like and consist of letters, digits and underscores. They must start with a letter, underscore or dollar sign.

If you stick to the European standard, ECMAScript, CSS1 and the W3's DOM Level1 model, you will have a script that can be expected to run on most browsers without too many glitches.

Browsers have their own additions, but you seldom really need those.

========

These comment tags should be there for the sake of browsers that don't support scripting.

========

Add 1 to cnt, two times. There's a difference between the operators used, but in this context the effect is the same.