Sum of Even Numbers (Set 8)

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

Example 1

sumEvenNumbers()
Input
nums = [10, 53, 57, 38, -2, 47, 38, 43, -25, -24, 7, 50, 31, -18, 40, -30, -9, 46, 17, 7, -4, -4, 13, 3, 15, 36, 7, 24, -15, 1, 11, -25, 21, 47, 41, 26, 56, -15, 55, -11, -30, 44, 48, 59, 23]
Output
344

Why

`sumEvenNumbers` returns `344` for this input.

Example 2

sumEvenNumbers()
Input
nums = [49, 41, 43, 51, 46, -23, 27, 50, 36, 30, -18, -9, 21, -4, 13, -17, 7, 38, 37, 9, -22, 31, -24, 3, 31, 40, 10, -5, 15, 27, 24, -6, 0, 46, 8, 30, 17, -17, 3, -7, 26, 7, 21]
Output
310

Why

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