For this Question: Write a function called oddball_sum which takes in a list of numbers and returns the sum of all the odd elements.
Try to solve with and without reduce function.An array containing numbersSum of all the odd numbers in that arraySample Input:-
1 3 5 4

Sample output:-
9

Explanation-
1+3+5=9, I have written this Solution Code: function oddball_sum(nums) {
// final count of all odd numbers added up
let final_count = 0;
// loop through entire list
for (let i = 0; i < nums.length; i++) {
// we divide by 2, and if there is a remainder then
// the number must be odd so we add it to final_count
if (nums[i] % 2 === 1) {
final_count += nums[i]
}
}
console.log(final_count);
}
, In this Programming Language: JavaScript, Now tell me if this Code is compilable or not?