Open this example in the interactive library
Source code
const numbers = [1, 2, 3, 4, 5];
const evenSquares = numbers
.filter(num => num % 2 === 0)
.map(num => num ** 2);
console.log(evenSquares); // Output: [4, 16]

Preserved from the original JavaScript Field Guide. Some entries are React fragments that require the surrounding component.
Open this example in the interactive library
const numbers = [1, 2, 3, 4, 5];
const evenSquares = numbers
.filter(num => num % 2 === 0)
.map(num => num ** 2);
console.log(evenSquares); // Output: [4, 16]