Lazo Lab Sign up

Web Development / JavaScript

Lesson 18 of 30

Functions and arrow functions

Functions work like Python's. Arrow functions are a shorter way to write them.

Key points

  • function add(a, b) { return a + b; }
  • const add = (a, b) => a + b;
  • Functions can be passed around
const double = (n) => n * 2;
console.log([1, 2, 3].map(double)); // [2, 4, 6]
Watch a video on thisOpens YouTube search results for “Functions and arrow functions” in a new tab

Quiz · +10 XP

What does [1, 2, 3].map(n => n * 2) give?

Log in to save progress and earn XP.