Sum of Even Numbers (Set 14)

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

Example 1

sumEvenNumbers()
Input
nums = [0, 19, 9, 56, 51, 21, 6, 37, -1, 46, -28, 6, -7, -27, -19, -4, -23, -10, -18, 25, 53, 31, 25, 58, 14, -18, 23, -27, 8, -18, -13, -11, 4, 10, 53, 60, 30, 46, 27, -12, 23, -3, 52, -20, -3, -12, 27, 4]
Output
260

Why

`sumEvenNumbers` returns `260` for this input.

Example 2

sumEvenNumbers()
Input
nums = [34, 60, -14, 4, 29, -8, 7, 4, 20, -10, 37, 39, 24, 3, 54, 55, -14, 52, 30, -27, 57, -12, 47, 7, 7, -15, 24, 23, -26, -26, 29, 28, 57, 17, -23, -8, 59, 9, -25, 37, -24, 23, 6, 9, -1, 38, 35, 44]
Output
280

Why

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