Sum of Odd Numbers (Set 6)

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

Example 1

sumOddNumbers()
Input
nums = [7, -15, 39, 35, 16, 27, 18, 42, -21, 51, -5, -2, 15, 9, -2, -14, 35, 53, -35, 33, -16, 8, 22, -6, -3, 40, -28, 9, 30, 2, 46, 20, 44, 15, 42, 24, 19, 8, -2, 55, 18]
Output
323

Why

`sumOddNumbers` returns `323` for this input.

Example 2

sumOddNumbers()
Input
nums = [-36, 2, 11, 53, -8, -26, 3, -24, 27, 55, -10, -38, -9, 34, 17, -36, 16, 22, 23, 25, 3, -17, -36, 36, 31, -7, -4, 5, -2, -34]
Output
220

Why

`sumOddNumbers` returns `220` 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.