Sum of Odd Numbers (Set 1)

Easy

Given an array of integers nums, return the sum of all its odd values, or 0 when every value is even.

Sum of Odd Numbers (Set 1) — the data. This set runs 4 cases: nums holds arrays of 4–9 items, with values from -28 to 48. The hidden cases are the largest of the set.

Example 1

sumOddNumbers()
Input
nums = [22, 4, 48, 10]
Output
0

Why

`sumOddNumbers` returns `0` for this input.

Example 2

sumOddNumbers()
Input
nums = [-19, 15, -28, 4, 22]
Output
-4

Why

`sumOddNumbers` returns `-4` 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 sumOddNumbers in the editor and return the answer — printing it is never graded.