Double Each Value (Set 10)

Easy

Given an array of integers nums, return a new array where every value has been multiplied by 2.

Double Each Value (Set 10) — the data. This set runs 4 cases: nums holds arrays of 38–45 items, with values from -60 to 70. The hidden cases are the largest of the set.

Example 1

doubleEach()
Input
nums = [10, 20, 15, 10, 30, -12, 10, 48, 40, 9, 44, 65, -18, -18, -17, 30, -20, -30, -49, 11, 41, 35, -20, 62, 43, -55, 4, -16, 50, 3, 22, 43, 0, 53, -9, 70, 22, 54]
Output
[20, 40, 30, 20, 60, -24, 20, 96, 80, 18, 88, 130, -36, -36, -34, 60, -40, -60, -98, 22, 82, 70, -40, 124, 86, -110, 8, -32, 100, 6, 44, 86, 0, 106, -18, 140, 44, 108]

Why

`doubleEach` returns `[20, 40, 30, 20, 60, -24, 20, 96, 80, 18, 88, 130, -36, -36, -34, 60, -40, -60, -98, 22, 82, 70, -40, 124, 86, -110, 8, -32, 100, 6, 44, 86, 0, 106, -18, 140, 44, 108]` for this input.

Example 2

doubleEach()
Input
nums = [-29, 9, 29, 42, -13, 9, 28, -36, -14, 46, 37, -55, 62, 68, -22, 0, 20, -24, -2, -25, 18, 52, 34, -41, 12, -21, -35, 18, 18, 65, -42, -18, 35, 59, -55, -3, 40, 35, -46, 64, -33, 46, -53, -47, -25]
Output
[-58, 18, 58, 84, -26, 18, 56, -72, -28, 92, 74, -110, 124, 136, -44, 0, 40, -48, -4, -50, 36, 104, 68, -82, 24, -42, -70, 36, 36, 130, -84, -36, 70, 118, -110, -6, 80, 70, -92, 128, -66, 92, -106, -94, -50]

Why

`doubleEach` returns `[-58, 18, 58, 84, -26, 18, 56, -72, -28, 92, 74, -110, 124, 136, -44, 0, 40, -48, -4, -50, 36, 104, 68, -82, 24, -42, -70, 36, 36, 130, -84, -36, 70, 118, -110, -6, 80, 70, -92, 128, -66, 92, -106, -94, -50]` for this input.
Constraints
0 <= nums.length <= 10^5
-10^4 <= nums[i] <= 10^4
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

Arrays

Implement doubleEach in the editor and return the answer — printing it is never graded.