Concepts·7 / 9

Functions: named reusable blocks

~6 min read

A function is a chunk of code with a name. You call it whenever you need its work done.

function greet(name) {
  return 'Hello, ' + name + '!';
}

console.log(greet('World'));
console.log(greet('Aurelus'));

Functions take inputs (parameters) and usually return a result. They are the primary way to keep code organised.

Made with Emergent