Functions allow us to group code into reusable blocks. They can accept inputs, perform tasks, and return values.
Use the function
keyword to define a function:
function greet(name) {
console.log("Hello, " + name + "!");
}
Call a function by writing its name followed by parentheses:
greet("Alice");
Create a function that takes two numbers as parameters and returns their sum. Call the function with two numbers and log the result.
Answers: A block of code that performs a task; by its name and parentheses; to output a value.