</> CodeWithMe
Sign in
← ⚡ JavaScript from Scratch

Functions

There are two popular ways to declare a function:

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

const square = (x) => x * x; // arrow function

return gives back a result — you can store it in a variable or print it.

Challenge

Write a function sum(a, b) that returns the sum of two numbers.