This statement tells the browser to write "Hello Dolly." inside an HTML element with id="demo":
The statements are executed, one by one, in the same order as they are written.
In this example x, y, and z are given values, and finally z is displayed:
var y = 6;
var z = x + y;
document.getElementById("demo").innerHTML = z;
Add a semicolon at the end of each executable statement:
b = 6;
c = a + b;
When separated by semicolons, multiple statements on one line are allowed:
The following lines are equivalent:
A good practice is to put spaces around operators ( = + - * / ):
For best readability, programmers often like to avoid code lines longer than 80 characters.
The purpose of code blocks is to define statements to be executed together.
document.getElementById("demo").innerHTML = "Hello Dolly.";
document.getElementById("myDIV").innerHTML = "How are you?";
Here is a list of some of the keywords you will learn about in this tutorial: