Array.map III - numbers

Easy
9
71.4% Acceptance

Write a function called doubleNumbers(numbers) that takes an array of numbers as an argument and returns a new array with every element of the input array doubled.

Instructions

  • You should return a new array.
  • If the input array is empty, then return an empty array.
  • The input array will contain only numbers.

Example test cases

const numbers = [1, 2, 3, 4, 5]; const doubledNumbers = doubleNumbers(numbers); console.log(doubledNumbers); // Output: [2, 4, 6, 8, 10]

Hints

  • You can create a new array, loop over the input array numbers and push the transformed element to the new array.
  • You can use the built-in method .map() method.
  • Multiply each number by 2 to double it.