Why are my numbers not multiplying?


#1



https://www.codecademy.com/en/courses/ruby-beginner-en-XYcN1/2/5?curriculum_id=5059f8619189a5000201fbcb

Oops, try again. It looks like your iterator didn't print out double the value of each item of the odds array. Make sure to multiply each item by 2.

odds = [1,3,5,7,9]

# Add your code below!
odds.each do |i|
i * 2
print i
end


#2

i * 2 does not change the value of i, it simply returns new value. If you want to change value of i you have to assign returned value to the variable:

i = i * 2

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.