Sum of Even Numbers (Set 13)

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 13) — 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 = [-3, -19, 6, -23, 54, -24, 45, 12, 18, 7, 49, -23, -24, 24, 50, -9, -18, 50, 30, 34, -24, 59, 23, 46, 15, 1, 17, 16, -10, 6, 49, -22, -10, -17, 12, -1, -22, 3, 53, 35, 15, -16, 32, 51, -18, -6, 22, -23]
Output
218

Why

`sumEvenNumbers` returns `218` for this input.

Example 2

sumEvenNumbers()
Input
nums = [-25, -18, -24, -7, 0, 6, -21, -21, -15, 55, -3, 7, -11, -19, 39, -15, -5, 1, -13, 58, 1, -20, -27, 0, 51, 13, 11, -22, 16, -18, 49, -17, 60, 59, 42, 6, 57, 10, -8, 6, -18, 36, -25, -12, -6, -19, 37, 1]
Output
94

Why

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