Functions
A function groups code you can run many times. It can take parameters and return a value with return.
Arrow functions are a short form: const double = (x) => x * 2;
Example
function greet(name) {
return "Hello, " + name + "!";
}
const double = (x) => x * 2;
console.log(greet("Ada"));
console.log(double(21));Exercise
Send a value back from the function.
function add(a, b) { a + b; }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.