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"
end

Please help. Thank you!

1 Like

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
end
1 Like

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

1 Like

I was having similar trouble, but I finally decided to actually multiply each number:
odds = [12,32,52,72,9*2]
odds.each do |odds|
print “#{odds}”
end

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
end

4 Likes

like this placeholder *= 2

1 Like

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
end

2 Likes