Sum of Even Numbers (Set 10)

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

Example 1

sumEvenNumbers()
Input
nums = [56, -15, 42, 45, 37, 39, 48, -28, 27, 11, 21, 0, -22, 34, -6, -27, 38, -1, 1, 14, 4, 20, 21, 39, 48, 23, 54, 29, -17, 34, 7, 57, -15, -14, 24, 3, -14, -24, -29, 15, -10, 4, 2, 6, 39]
Output
310

Why

`sumEvenNumbers` returns `310` for this input.

Example 2

sumEvenNumbers()
Input
nums = [30, -25, -26, 56, 55, 43, -28, -8, -2, 29, 10, 44, -10, 1, 48, 21, 46, 31, -6, 17, 56, 56, 48, -17, -13, 27, 25, 10, -15, 34, 29, 50, 4, 3, 48, 57, 0, 46, 2, -26, -12, 39]
Output
470

Why

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