CodePeek
Practice / ArraysBack to CodePeek

JavaScript map: Map a new path

Puzzle 8 of 15 · map

Read a map callback that doubles numbers, then compare logs of the original array and the returned array. Predict both lines. Choose an output below, then check the explanation. No signup needed. Browse puzzles by topic →

Arrays / mapJavaScript
const nums = [1, 2, 3];
const doubled = nums.map(n => n * 2);
console.log(nums.join(","));
console.log(doubled.join(","));

Predict the console output. Each line is a separate log.

What’s the output?

Choose the output

Starter puzzles 15