Easy

Double the Numbers

Description

In this challenge, your task is to write a function that takes an array of numbers and returns a new array where each number is doubled.

The 'map()' method is a useful tool that allows you to transform elements in an array and create a new array without modifying the original one.

Example Usage

doubleNumbers([0, -1, 5]); // ➞ [0, -2, 10]
doubleNumbers([]); // ➞ []

Constraints

  • The input will always be an array of numbers.
  • The function should return a new array, not modify the original.
  • The array may contain positive and negative numbers, as well as zero.

window code 2Test Cases

Input:

0

Expected Output:

[
  0,
  -2,
  10
]