Sum of Even Numbers (Set 9)

Easy

Given an array of integers nums, return the sum of all its even values. 0 counts as even, and an array with no even value scores 0.

Sum of Even Numbers (Set 9) — the data. This set runs 4 cases: nums holds arrays of 39–48 items, with values from -29 to 59. The hidden cases are the largest of the set.

Example 1

sumEvenNumbers()
Input
nums = [6, 58, 29, 17, 47, -2, 54, 52, 5, -1, 40, -18, -9, -3, -22, 49, 18, -12, -20, 2, 1, -2, 30, -4, 25, -29, 20, 19, -19, 58, 5, -21, 16, 6, 19, 19, 37, 10, 35, 39, 8, 58, 48, 15, 52]
Output
456

Why

`sumEvenNumbers` returns `456` for this input.

Example 2

sumEvenNumbers()
Input
nums = [-3, -7, 12, 45, -1, 57, 36, 9, -22, 5, 41, 40, 23, 27, 11, 0, 33, 8, -7, 35, 58, -19, -8, -25, 22, -1, 55, 46, 51, 7, 6, 22, 32, 26, 52, -8, 56, 55, -17, 51, 0, 37, -21, -5]
Output
378

Why

`sumEvenNumbers` returns `378` for this input.
Constraints
2 <= nums.length <= 10^4
-10^3 <= nums[i] <= 10^3
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

ArraysMath

Implement sumEvenNumbers in the editor and return the answer — printing it is never graded.