Lesson 12 loops and iterators


#1

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

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.


#2

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.


#3

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


#4

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


#5

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
end


#6

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

Add your code below!

odds.each do |item|

print item*2
end


#7

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

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


#8

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.


#9

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