1. Variables

Variables are used to store data. In JavaScript, you declare variables using var, let, or const.

let name = "John";      // Variable that can be reassigned
const age = 30;         // Constant variable that cannot be reassigned
var isStudent = true;   // Older way to declare variables, function-scoped


2. Data Types

JavaScript has different data types, including numbers, strings, booleans, and arrays.

let number = 42;            // Number
let string = "Hello World"; // String
let isActive = false;       // Boolean
let numbers = [1, 2, 3];    // Array


3. Operators

Operators are used to perform operations on values and variables.

let sum = 10 + 5;           // Arithmetic operator
let isEqual = (10 === 10);  // Comparison operator
let isTrue = (true && false); // Logical operator


4. Functions

Functions allow you to reuse blocks of code.

Function Declaration

function greet(name) {
    return "Hello, " + name;
}

// Function Call
let message = greet("John"); // "Hello, John"

Assignment #1

Write a function sum that finds the sum of two numbers.