Hi,
I am new to Ruby on Rails. I am practicing problems to better
understand coding. I understand the logic but I am not able to put in
proper codes. Could someone please solve the following problem for me?
oddball_sum
Write a function oddball_sum(numbers), which takes in an array of
integers and returns the sum of all the odd elements.
oddball_sum(numbers)
i = 0
while i < numbers.length
if (numbers % 2 !== 0)
return numbers[i] += 1
i += 1
end
return result
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cbebbdfd5307d9f34ea620f13d5ec2ef%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment