Try It Out! mutiply by 2 help me pls


#1
           when i made this code it said it wonts odd numbers

odds = [1,3,5,7,9]
odds.each { |x| puts x }
odds.each do |x|
print x
end
and its odds up here
1
3
5
7
9
13579[1, 3, 5, 7, 9]

by it said: Oops, try again. It looks like your iterator didn't print out double the value of each item of the odds array. Make sure to multiply each item by 2.
what dose that mean?


#2

un less its like this maybe

odds = [ 1*2,3*2,5*2,7*2,9*2,]
is it?


#3

The above line is not needed.

What happens if you write,

    print x * 2

?


#4

i got it u multiply like this
odds = [ 1*2,3*2,5*2,7*2,9*2,]
odds.each { |x| puts x }
odds.each do |x|
print x
end

THX :smiley:


#5

You don't need to multiply the numbers inside the array like:

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

All you need is what mtf said and use print x * 2 Like this:

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

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

ATENTION! -> If you try to do this with the puts it will end in error because the instructions tell you to use print!