Sum of Even Numbers (Set 6)

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 6) — the data. This set runs 4 cases: nums holds arrays of 35–48 items, with values from -30 to 60. The hidden cases are the largest of the set.

Example 1

sumEvenNumbers()
Input
nums = [-27, 10, -5, 44, 0, -14, 35, 16, -19, 26, 3, 14, 46, 43, 20, 14, 18, 19, 47, 12, 50, 44, -13, -26, 7, 18, 22, -29, 24, 15, 14, 12, -5, 16, 2, 59, 7, 36, 38, -8, 54, 53, 36]
Output
538

Why

`sumEvenNumbers` returns `538` for this input.

Example 2

sumEvenNumbers()
Input
nums = [-24, -17, 15, 9, 60, 15, -5, 11, 44, 11, 44, -22, 46, 20, -11, 42, 5, -24, 5, 14, 22, 56, 9, -18, 59, 22, 53, 28, -6, 47, 12, -25, -18, 39, 23]
Output
298

Why

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