Skip to content

Your own functions

Read · 1 of 4

Inputs in, result out

function square(x) { return x * x; } makes a function called square. It takes x and gives back (returns) x × x.

A shorter way you'll see everywhere: const square = (x) => x * x; (an arrow function). Both work the same here.