Lesson 12 loops and iterators


odds = [1,3,5,7,9]
odds.each do |placeholder|
#Multiply placeholder by 2
#Print out placeholder
print item

Not sure what I am doing wrong currently sitting in class trying to do this since I have no clue what the instructors droning on about lol. Anyone that can offer some insight as to multiplying the filler id appreciate it. Thanks in advanced.


As you can see, they're asking you to multiply the variable placeholder by 2. If you don't remember how to multiply in Ruby, you should go back to the previous lessons, it's explained.


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

Add your code below!

odds.each do |x|
x *= 2
print "#{x}"

the item in | | can be anything you like like t,r, |t| ,|x| e.t.c


odds.each do |odds|
print odds


numbers.each { |item| puts item } # i = i * 2

numbers.each do |item| # i = i * 2

odds.each do |placeholder|
# Multiply placeholder by 2 # # p = p * 2
# Print out placeholder


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

Add your code below!

odds.each do |item|

print item*2


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

odds.each{ |x| print x*(2) }


This might help someone since I've struggled to find the solution. You need to use only one of the methods at once. Even if the two ways to put it are coded correctly and the result shows it works, the system won't let you progress.


I’ve tried all of these solutions and they didn’t seem to work >_> I still need some help on this!