Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Double Each

Working With Arrayseasy

Course · Section 11: Working With Arrays · Lecture 156: Data Transformations: map, filter, reduce

Implement `doubleAll(nums)` returning each number multiplied by two, using `map`.

Sample tests

Input: doubleAll([1,2,3])
Output: [2,4,6]
Input: doubleAll([])
Output: []

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Mutating the original array in a loop instead of mapping.

Learning resources

  • MDN: Array iteration methods
Visualize this concept: map, filter, and reduce →
Approach & explanation (try first)

map produces a new array with each value doubled.

Loading...
⌘/Ctrl + Enter

Run your code to see results.