Double Each Value (Set 6)

Easy

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

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

Example 1

doubleEach()
Input
nums = [-35, 9, 16, 64, -53, 31, 56, -4, 19, -16, -35, 2, 58, -28, -55, -25, -13, -5, -5, 60, 34, -41, -24, 19, 39, 58, -24, 36, 62, 2, 13, -29, -50, -37, -3, 49, 19, 29]
Output
[-70, 18, 32, 128, -106, 62, 112, -8, 38, -32, -70, 4, 116, -56, -110, -50, -26, -10, -10, 120, 68, -82, -48, 38, 78, 116, -48, 72, 124, 4, 26, -58, -100, -74, -6, 98, 38, 58]

Why

`doubleEach` returns `[-70, 18, 32, 128, -106, 62, 112, -8, 38, -32, -70, 4, 116, -56, -110, -50, -26, -10, -10, 120, 68, -82, -48, 38, 78, 116, -48, 72, 124, 4, 26, -58, -100, -74, -6, 98, 38, 58]` for this input.

Example 2

doubleEach()
Input
nums = [-41, 18, -15, 6, 51, 61, 57, 45, 58, 56, 33, -25, -47, -7, 52, 14, -32, 6, -31, -53, 46, -8, 17, -52, -52, -7, -47, 63, 64, -33, -59, 39, -57, 15]
Output
[-82, 36, -30, 12, 102, 122, 114, 90, 116, 112, 66, -50, -94, -14, 104, 28, -64, 12, -62, -106, 92, -16, 34, -104, -104, -14, -94, 126, 128, -66, -118, 78, -114, 30]

Why

`doubleEach` returns `[-82, 36, -30, 12, 102, 122, 114, 90, 116, 112, 66, -50, -94, -14, 104, 28, -64, 12, -62, -106, 92, -16, 34, -104, -104, -14, -94, 126, 128, -66, -118, 78, -114, 30]` 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.