Hi,

I am currently learning Javascript and need the Ruby answer to the

following answer translated into Javascript. Here is the challenge;

Write a function oddball_sum(numbers), which takes in an array of

integers and returns the sum of all the odd elements.

Ruby CORRECT answer below;

def oddball_sum(numbers)

result = 0

numbers.each { |n| result += n if n %2 != 0 }

return result

end

puts oddball_sum([1,4,1,2])

My WRONG Javascript answer;

function oddball_sum(numbers) {

var answer = 0;

for (var i = 0; i <= numbers.length; i++){

if (numbers[i] % 2 !== 0)

return answer += i;

}

}

oddball_sum ([1,2,3,4,5])