Sum of Odd Numbers (Set 12)

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 12) — 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 = [53, -37, -40, 6, -26, 29, 39, 46, 46, 12, 9, 47, 38, 3, 46, 45, 6, 44, -2, -36, 21, 55, 38, 26, -20, -23, 35, 31, -21, -22, -30, 55, -24, -39, 44, -37, -14, -12, 41, -29, 38, -25, 14, -19, 2, -38]
Output
233

Why

`sumOddNumbers` returns `233` for this input.

Example 2

sumOddNumbers()
Input
nums = [43, 43, -8, -30, -14, 16, 8, -15, 55, 15, 11, -16, 6, -27, 40, 37, 37, 15, 15, -10, -9, 29, -35, 52, 14, 49, -5, 21, -15, -16, -5, -18, -4, 6, -27, 3, -15, 17, 35, 27, 35, 8, 4, 14, 22, 12, 5]
Output
339

Why

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