Sum of Odd Numbers (Set 8)

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

Example 1

sumOddNumbers()
Input
nums = [-14, 17, 49, 30, 7, 30, 23, 35, 29, 32, 39, -18, 32, -36, 22, 3, 41, 29, 34, -11, 25, -38, 25, 19, -15, -26, 43, 14, -23, 28, 9, 12, 32, -23, 20]
Output
321

Why

`sumOddNumbers` returns `321` for this input.

Example 2

sumOddNumbers()
Input
nums = [1, 2, 47, 50, -24, -37, -4, -6, -4, -6, 1, 39, -22, -25, 7, 25, -8, 30, 3, 48, -20, -37, 24, 33, 18, -38, 29, -31, -20, 50, 0, -35, 31, -40, 24, 1, 38, 43, 7, -9, 45, -24, 53]
Output
191

Why

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