Same recipe, less ink
Modern JavaScript has a shorter way to write functions, using an arrow =>. You'll see it in lots of real code, so let's learn to read and write it.
From function to arrow
function double(n) {
return n * 2;
}
const doubleArrow = (n) => {
return n * 2;
};
const doubleShort = (n) => n * 2;
console.log(double(4), doubleArrow(4), doubleShort(4));const greet = () => console.log("Hello!");
const add = (a, b) => a + b;
greet();
console.log(add(3, 4));