JavaScript Basics

JavaScript Basics

JavaScript is one of the most popular modern web technologies! As your JavaScript skills grow, your websites will enter a new dimension of power and creativity.

Add this code to the main.js file

1const myHeading = document.querySelector('h1');
2myHeading.textContent = 'Hello world!';

Example

Assign values to variables and add them together:

1var x = 5;         // assign the value 5 to x
2var y = 2;         // assign the value 2 to y
3var z = x + y;     // assign the value 7 to z (5 + 2)