JavaScript

In 1995, JavaScript was created by Brendan Eich while he was working at Netscape. The founder of Netscape, Marc Andreessen, wanted the web to become
more dynamic with animations and interactions. Before JavaScript was called JavaScript, it was originally called Mocha.

Mocha was for smaller scripting tasks for amateurs and designers while Java, was meant for enterprise systems. The idea was for Mocha to be a Java scripting companion.

It was not until May 1995 when became LiveScript and was integrated in Netscape. By December, Netscape and Java closed on a deal and it was renamed to JavaScript.

JavaScript is a dynamic programming language, which means that it executes while the program is running. Whereas C++ executes after it is compiled.

JavaScript is used to create interaction between the user and the webpage

Variables

A variable is the name of a location in the computer's memory.

Like HTML, a variable cannot start with:

Variables can never contain spaces, nor can JavaScript keywords be used for a variable.

In addition, variable names are case sensitive (i.e. someArt is not the same as SomeArt or Someart, which are 3 separate variable names).

Using script tags, <script></script>, in the head section of your HTML document to start the JavaScript function.

From there, you can define your variables, create functions, use decision or repitition structures (i.e. if/else versus while or while ... do).

You can use counters that increment or decrement in your loops and use sentinel values to escape a program.

Say you want to add all integers from 1 to 10 in a script. How do you do that?

Example:

<script>

function getSum()

{

var num = 0;

var i = 1;

for (i = 1; i < 11; i++)

num = num + i;

}

</script>

In this example, you are creating a function to get the sume of numbers between 1 to 10.
Two variables, num and i, are declared and assigned numeric values.

The for loop will start at 1 and 1 is less than 11 so the loop will increment by 1.

Next, the loop starts at 2 which is less than 11 and increments by 1 again.

This keeps happening until 11 is not less than 11 at which point the loop becomes false and terminates.

JavaScript is far more complex than this for many webpages,
but these are the foundational blocks of learning how to make webpages interactive for users.