Lesson 5 of 10
Functions
Functions are reusable blocks of code. Define them with the function keyword or as arrow functions. They can accept inputs (parameters) and return outputs.
JS
// Regular function
function greet(name) {
return "Hello, " + name;
}
// Arrow function
const add = (a, b) => a + b;
console.log(greet("Ali")); // "Hello, Ali"
console.log(add(3, 4)); // 7