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.