JavaScript Lesson 4

Functions

Functions let you reuse blocks of code. They are defined with the function keyword or arrow syntax.


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

// Arrow function
const greetArrow = (name) => "Hello, " + name;