JavaScript Programs

A computer program is a list of "instructions" to be "executed" by the computer. JavaScript is a programming language and its syntax is the set of rules, how JavaScript programs are constructed. These program instructions are called statements, which are separated by semicolons, all of which are placed inside the <script> element:

HTML file: Displayed by browser:
<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Statements</h1>
<p>Statements are separated by semicolons.</p>
<p>The variables x, y, and z are assigned the values 5, 6, and 11:</p>

<p id="demo"></p>

<script>
    var x = 5;
    var y = 6;
    var z = x + y;
    document.getElementById("demo").innerHTML = z;
</script>

</body>
</html>

JavaScript Statements

Statements are separated by semicolons.

The variables x, y, and z are assigned the values 5, 6, and 11:

In HTML, JavaScript programs can be executed by the web browser.

BackTable of ContentsNext