12. Try It Out!


#1

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!


#2

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


#3

Mine is not working too, here is my code.

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

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

#4

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


#5

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


#6

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


#7

like this placeholder *= 2


#8

thank you for the help
you really saved me


#9

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