JS Syntax

Understand the basic syntax rules of JavaScript.

Examples

Declaring Variables

How to declare and assign values to variables.

let x;
x = 6;
let y = 5;
let z = x + y;
console.log(z);

Using Operators

Doing basic arithmetic with operators.

let a = 10;
let b = 5;
let sum = a + b;
let product = a * b;
console.log("Sum:", sum);
console.log("Product:", product);

String Concatenation

Combining strings (text) together.

let firstName = "John";
let lastName = "Doe";
let fullName = firstName + " " + lastName;
console.log(fullName);

Comments

Reading comments in code.

// This is a single line comment
let x = 5; 

/* This is a
multi-line comment */
let y = 10;

Test Your Knowledge

JavaScript Quiz

No quiz available for this topic yet.