Lesson 2: Variables and Functions

JavaScript uses variables to store data and functions to perform actions.


// Declare a variable
let name = "John";

// Use the variable
console.log("Hello, " + name);

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

// Call the function
console.log(greet("Alice"));