Skip to main content
🟨 JavaScript Foundations

Transform with map()

.map() builds a new array by running a function on every item β€” the original array is left untouched.

[1, 2, 3].map((n) => n + 1); // [2, 3, 4]

Your task

Write doubleAll that takes an array of numbers and returns a new array with every number doubled. An empty array returns [].

⚑ 30 XP

🧱 Code blocks

Drag a block into the editor, or tap it to drop it in where your cursor is. Add them in order to build your answer.

solution.jsRuns in your browser
Loading editor…
Tests3 to pass
doubleAll([1,2,3]) β†’ [2,4,6]
doubleAll([]) β†’ []
handles negatives

Run your code to check these.