12. Try It Out!


What am I doing wrong? Trying to answer my question since 2 months ago.

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

numbers.each do |odds * 2 |
puts "odds"

Please help. Thank you!


Hi albert,

Would you please tell why you are doing this:

numbers.each do |odds * 2 |

the part inside | | is reserved for writing a variable name which will represent each element in the list. So, you should do:

numbers.each do |odds|

Also, do you know the different between "odds" string and odds variable? :wink: It is affecting this puts "odds".


Mine is not working too, here is my code.

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

odds.each do |placeholder|
  placeholder * 2
  print placeholder


Hint: You need to re-assign the result of placeholder * 2 back to placeholder.


I was having similar trouble, but I finally decided to actually multiply each number:
odds = [1*2,3*2,5*2,7*2,9*2]
odds.each do |odds|
print "#{odds}"


inside the | | replace it with odds then say what to do with odds like:
odds *= 2
then print/puts odds without the quotation marks

odds = [1, 2, 3, 4, 5]
odds.each do |something|
something *= 2
puts something


like this placeholder *= 2


thank you for the help
you really saved me


this what I ended up with and it worked fine.

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

Add your code below!

odds.each do |odds|
odds *=2
print odds