Sum of Odd Numbers (Set 11)

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

Example 1

sumOddNumbers()
Input
nums = [9, 31, 22, -26, -20, 14, 10, 51, -20, -2, 40, -40, -10, 46, 8, 20, 45, 30, -3, -26, -22, -25, 23, -11, 11, 18, 49, 28, 7, 24, 31, -9, -19, 21, 2, 32, 27, 3, 16, -37, 5, 3, 12, -20, -4, -14, -22]
Output
212

Why

`sumOddNumbers` returns `212` for this input.

Example 2

sumOddNumbers()
Input
nums = [-2, -25, -23, 3, -4, -3, -5, 49, 46, 28, 7, -34, 44, -5, -18, 50, 53, -16, 22, 27, -39, -7, -17, -29, 41, -6, 47, 19, 21, -8, -14, -31, 40, -33, -8, -18, 40, 48, 55, 26, 47, 53, 20, 9, 28, 44, -7, -22]
Output
207

Why

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