Sum of Odd Numbers (Set 5)

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

Example 1

sumOddNumbers()
Input
nums = [32, 17, -24, 49, 29, 25, -17, -36, 47, 40, 11, -30, -4, 23, -34, 11, 9, -1, 21, -20, 15, -3, 29, 44, -30, 12, 17, -29, 54, -31, 29, -25, -6, 33, -30]
Output
259

Why

`sumOddNumbers` returns `259` for this input.

Example 2

sumOddNumbers()
Input
nums = [49, -32, -35, -10, -14, 5, -27, 15, -30, -1, 16, 6, -25, -10, 52, 41, 28, -39, 47, 48, 7, -25, -1, 22, 11, 13]
Output
35

Why

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