Sum of Even Numbers (Set 7)

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

Example 1

sumEvenNumbers()
Input
nums = [-22, -30, 53, 43, 8, 13, -27, 13, 23, 13, 11, 36, 8, 38, -2, -25, -29, 0, -5, 25, 10, 5, 15, 19, 59, 16, 60, 49, 7, -24]
Output
98

Why

`sumEvenNumbers` returns `98` for this input.

Example 2

sumEvenNumbers()
Input
nums = [4, 50, -24, 41, 18, 52, 14, 51, 15, -22, 54, -18, 14, 27, 12, 1, 55, 28, 33, 26, 60, 41, 52, 27, -25, 36, -23, -12, -24, 56, 46, 15, 16, 24, 56]
Output
518

Why

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