Sum of Even Numbers (Set 2)

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

Example 1

sumEvenNumbers()
Input
nums = [52, 60, 52, 42, 60, -11, 31, 8, 32, -4]
Output
302

Why

`sumEvenNumbers` returns `302` for this input.

Example 2

sumEvenNumbers()
Input
nums = [56, 43, -11, -9, 1, 3, 25, 40, -1, 21]
Output
96

Why

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