Double Each Value (Set 14)

Easy

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

Double Each Value (Set 14) — 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 = [-18, 61, 51, 22, 66, -45, 58, -47, -54, 68, -56, 6, -5, 43, -49, 9, 48, -3, -5, 2, 37, -21, 16, -6, -44, 0, -24, 45, -28, -56, -9, 46, 70, -1, 49, -22, 7, 37, -20, -25, -10, 30, 67, 47, -43, 53, -58, 55]
Output
[-36, 122, 102, 44, 132, -90, 116, -94, -108, 136, -112, 12, -10, 86, -98, 18, 96, -6, -10, 4, 74, -42, 32, -12, -88, 0, -48, 90, -56, -112, -18, 92, 140, -2, 98, -44, 14, 74, -40, -50, -20, 60, 134, 94, -86, 106, -116, 110]

Why

`doubleEach` returns `[-36, 122, 102, 44, 132, -90, 116, -94, -108, 136, -112, 12, -10, 86, -98, 18, 96, -6, -10, 4, 74, -42, 32, -12, -88, 0, -48, 90, -56, -112, -18, 92, 140, -2, 98, -44, 14, 74, -40, -50, -20, 60, 134, 94, -86, 106, -116, 110]` for this input.

Example 2

doubleEach()
Input
nums = [-49, 11, 40, 22, 18, -47, 12, -34, -25, 19, -40, -7, 20, 8, -51, 61, -30, -29, -16, -3, -37, 40, -38, 30, 69, -9, -24, 7, -44, -11, -46, 28, -55, -41, 59, -20, 66, 10, -25, -31, 15, 9, 24, 4, 23, 31, 6, -6]
Output
[-98, 22, 80, 44, 36, -94, 24, -68, -50, 38, -80, -14, 40, 16, -102, 122, -60, -58, -32, -6, -74, 80, -76, 60, 138, -18, -48, 14, -88, -22, -92, 56, -110, -82, 118, -40, 132, 20, -50, -62, 30, 18, 48, 8, 46, 62, 12, -12]

Why

`doubleEach` returns `[-98, 22, 80, 44, 36, -94, 24, -68, -50, 38, -80, -14, 40, 16, -102, 122, -60, -58, -32, -6, -74, 80, -76, 60, 138, -18, -48, 14, -88, -22, -92, 56, -110, -82, 118, -40, 132, 20, -50, -62, 30, 18, 48, 8, 46, 62, 12, -12]` 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.