Double Each Value (Set 13)

Easy

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

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

Example 1

doubleEach()
Input
nums = [48, 8, 42, -37, 57, 57, -16, -42, -7, 54, -59, -59, -22, -37, 38, -16, 3, 20, 32, 69, 5, -15, 1, 15, -4, 11, 1, 63, -52, -35, 30, -58, 60, 39, 11, -31, -55, 39, 19, 13, 10, 44, -29, 58, -47, 68, 65, -42]
Output
[96, 16, 84, -74, 114, 114, -32, -84, -14, 108, -118, -118, -44, -74, 76, -32, 6, 40, 64, 138, 10, -30, 2, 30, -8, 22, 2, 126, -104, -70, 60, -116, 120, 78, 22, -62, -110, 78, 38, 26, 20, 88, -58, 116, -94, 136, 130, -84]

Why

`doubleEach` returns `[96, 16, 84, -74, 114, 114, -32, -84, -14, 108, -118, -118, -44, -74, 76, -32, 6, 40, 64, 138, 10, -30, 2, 30, -8, 22, 2, 126, -104, -70, 60, -116, 120, 78, 22, -62, -110, 78, 38, 26, 20, 88, -58, 116, -94, 136, 130, -84]` for this input.

Example 2

doubleEach()
Input
nums = [49, 3, 18, -55, -45, -2, 34, -1, -35, 24, -41, -4, -36, 70, 47, 51, -39, -50, 4, 1, -8, -5, 7, 42, 21, 55, 59, 5, 21, 61, -2, -31, -2, 2, -26, -32, -27, -31, -27, 49, 6, 10, -48, 14, 65, 7, 2, -30]
Output
[98, 6, 36, -110, -90, -4, 68, -2, -70, 48, -82, -8, -72, 140, 94, 102, -78, -100, 8, 2, -16, -10, 14, 84, 42, 110, 118, 10, 42, 122, -4, -62, -4, 4, -52, -64, -54, -62, -54, 98, 12, 20, -96, 28, 130, 14, 4, -60]

Why

`doubleEach` returns `[98, 6, 36, -110, -90, -4, 68, -2, -70, 48, -82, -8, -72, 140, 94, 102, -78, -100, 8, 2, -16, -10, 14, 84, 42, 110, 118, 10, 42, 122, -4, -62, -4, 4, -52, -64, -54, -62, -54, 98, 12, 20, -96, 28, 130, 14, 4, -60]` 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.