<script>

var x = 100;

var helloWorld = &#x201C;Hello World!;

</script>

In this example, the x variable will contain the number 100, while the helloWorld variable will contain the text ‘Hello World!’.

Naming variables

When naming things with JavaScript, such as variables, just like with HTML ids and classes, we can’t have any spaces in the word. However, when working with programming languages, it is common practice to (instead of using hyphens) replace spaced words with a style of writing known as camelCase. The basic principle of camelCase, is that for each new word, we remove the space and replace the first letter of the new word with a capital letter, except the very first letter of the phrase, which is always lowercase. For example, the phrase ‘My New Variable’ would become ‘myNewVariable’. One of the main reasons we have different ‘rules’ for naming things between JavaScript and HTML, is to help us quickly decipher the difference between the two when we are working with HTML in JavaScript (more on that later).