Double Each Value (Set 12)

Easy

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

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

Example 1

doubleEach()
Input
nums = [51, -19, -30, 54, -46, -12, 28, 4, -40, 39, 17, 0, 2, -25, -54, -48, 45, 10, 63, 52, -34, 58, -53, -31, 13, -33, 16, 25, 59, -54, 13, 27, 0, 9, -60, -18, -10, -32, 33, 61, 40, 20, -5, 66, 21, -54, -23, 46]
Output
[102, -38, -60, 108, -92, -24, 56, 8, -80, 78, 34, 0, 4, -50, -108, -96, 90, 20, 126, 104, -68, 116, -106, -62, 26, -66, 32, 50, 118, -108, 26, 54, 0, 18, -120, -36, -20, -64, 66, 122, 80, 40, -10, 132, 42, -108, -46, 92]

Why

`doubleEach` returns `[102, -38, -60, 108, -92, -24, 56, 8, -80, 78, 34, 0, 4, -50, -108, -96, 90, 20, 126, 104, -68, 116, -106, -62, 26, -66, 32, 50, 118, -108, 26, 54, 0, 18, -120, -36, -20, -64, 66, 122, 80, 40, -10, 132, 42, -108, -46, 92]` for this input.

Example 2

doubleEach()
Input
nums = [65, 9, 70, -51, 46, 13, 54, -3, 61, 15, -18, 20, 8, -41, -10, -58, 51, 60, -11, 63, 25, -49, -45, 2, -14, 15, 29, -40, 51, 51, 48, -56, 61, -23, 54, 32, -42, -20, 28, -25, 30, 3, 56, 5, 57, -9, 63]
Output
[130, 18, 140, -102, 92, 26, 108, -6, 122, 30, -36, 40, 16, -82, -20, -116, 102, 120, -22, 126, 50, -98, -90, 4, -28, 30, 58, -80, 102, 102, 96, -112, 122, -46, 108, 64, -84, -40, 56, -50, 60, 6, 112, 10, 114, -18, 126]

Why

`doubleEach` returns `[130, 18, 140, -102, 92, 26, 108, -6, 122, 30, -36, 40, 16, -82, -20, -116, 102, 120, -22, 126, 50, -98, -90, 4, -28, 30, 58, -80, 102, 102, 96, -112, 122, -46, 108, 64, -84, -40, 56, -50, 60, 6, 112, 10, 114, -18, 126]` 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.