JavaScript Beginner Day 3: Operators

Goal of this Day

Today you will learn:

By the end, you will be able to work with values and compare them.

Step 1: Arithmetic Operators

Used for calculations:


let a = 10;
let b = 5;

console.log(a + b); // 15
console.log(a - b); // 5
console.log(a * b); // 50
console.log(a / b); // 2

Step 2: Comparison Operators

Used to compare values:


console.log(a == b);   // false
console.log(a === 10); // true
console.log(a > b);    // true

Step 3: Logical Operators

Used to combine conditions:


let age = 20;
let hasID = true;

console.log(age >= 18 && hasID); // true
console.log(age < 18 || hasID);  // true

Practice


let a = 10;
let b = 5;

console.log(a + b);
console.log(a > b);

Task

Compare your age with 18 and print if you are an adult.

Example:


let age = 18;

console.log(age >= 18); // true or false

if(age >= 18) {
    console.log("You are an adult");
} else {
    console.log("You are not an adult");
}