11.2 Basic Syntax of JavaScript
Basic Syntax of JavaScript (15 mins)
<head> <script> // JavaScript code here </script> </head><body> <!-- Page content --> <script> // JavaScript code here </script> </body>
<script src="script.js"></script>
// This is a single-line comment console.log("Hello World");/* This is a multi-line comment It can span multiple lines */ console.log("Hello World");
let myVariable = "Hello"; let MyVariable = "World"; console.log(myVariable); // Outputs: Hello console.log(MyVariable); // Outputs: World
let x = 10; // Declare a variable x += 5; // Add 5 to x console.log(x); // Outputs: 15
let y = 20; let z = 30; console.log(y + z); // Outputs: 50
Student Activity (15 mins):
Last updated