Sum of Even Numbers (Set 3)

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 3) — the data. This set runs 4 cases: nums holds arrays of 13–23 items, with values from -29 to 58. The hidden cases are the largest of the set.

Example 1

sumEvenNumbers()
Input
nums = [2, -29, 30, 28, 17, 56, -19, -24, -6, 54, 47, 41, -4, -8]
Output
128

Why

`sumEvenNumbers` returns `128` for this input.

Example 2

sumEvenNumbers()
Input
nums = [6, -18, 1, -17, 11, -9, 0, 44, 37, 2, 27, -11, -9, 12, 2, -6, 20, -2, 21, -24, 58, 24, 50]
Output
168

Why

`sumEvenNumbers` returns `168` 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.