Double Each Value (Set 5)

Easy

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

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

Example 1

doubleEach()
Input
nums = [68, -17, 21, -45, -16, 55, -53, -39, -25, 29, -18, -8, 14, -34, 60, 35, -40, -32, 40, 38, 65, 43, 43]
Output
[136, -34, 42, -90, -32, 110, -106, -78, -50, 58, -36, -16, 28, -68, 120, 70, -80, -64, 80, 76, 130, 86, 86]

Why

`doubleEach` returns `[136, -34, 42, -90, -32, 110, -106, -78, -50, 58, -36, -16, 28, -68, 120, 70, -80, -64, 80, 76, 130, 86, 86]` for this input.

Example 2

doubleEach()
Input
nums = [7, -32, -41, 10, -54, -5, 65, -29, -53, -23, 7, -48, 29, -35, 47, -47, -28, 54, 46, 69, -46, 10, 17, 7, -35, -16, 19, -2]
Output
[14, -64, -82, 20, -108, -10, 130, -58, -106, -46, 14, -96, 58, -70, 94, -94, -56, 108, 92, 138, -92, 20, 34, 14, -70, -32, 38, -4]

Why

`doubleEach` returns `[14, -64, -82, 20, -108, -10, 130, -58, -106, -46, 14, -96, 58, -70, 94, -94, -56, 108, 92, 138, -92, 20, 34, 14, -70, -32, 38, -4]` 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.