Lesson 1 of 6
const and arrow functions
Modern JavaScript declares with const (or let when the value changes) and writes short functions with arrow syntax: const double = (x) => x * 2;
Without braces, the arrow returns the expression directly — ideal for one-line transformations.
const double = (x) => x * 2;
document.querySelector('#out').textContent = double(21);🎯 Exercise
Declare an arrow function double (const) that returns its argument times 2, then write double(21) into the #out paragraph.
PRO lesson
This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.
Discover PRO →