Sum of Even Numbers (Set 1)

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

Example 1

sumEvenNumbers()
Input
nums = [59, 39, 44]
Output
44

Why

`sumEvenNumbers` returns `44` for this input.

Example 2

sumEvenNumbers()
Input
nums = [-14, 54, 36]
Output
76

Why

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