Sum of Even Numbers (Set 11)

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

Example 1

sumEvenNumbers()
Input
nums = [38, 45, -26, 3, 16, -28, -29, 54, -18, 21, 38, -7, -1, 31, 30, 19, 33, 48, 41, 13, 10, 15, 29, 55, 18, -15, -20, -3, 50, 49, 30, 7, -23, 31, 32, -12, 15, 36, 29, 31, -27, 29, -30, 19, 44, 20]
Output
330

Why

`sumEvenNumbers` returns `330` for this input.

Example 2

sumEvenNumbers()
Input
nums = [22, 22, 58, 2, 16, 21, -3, 30, -21, 36, 11, 60, -11, -23, 2, -8, 34, 18, 10, 19, 34, 54, -27, 29, 45, -11, 6, -3, 12, 28, 19, 47, 6, 31, 28, -23, -29, 10, 23, 6, -4, 29, 12]
Output
494

Why

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