Multiplying an array by 2


I am having a really tough time multiplying an array by 2.

This is currently where I’m at


Hi try to remove the s to print



why doesn’t work with puts? I get the following error:

odds.each { |x|
puts “#{x*2}”

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.


HI like the insruction says…

Make sure to use print rather than puts, so your output appears on one line.


Yes. I read the instruction and it works with print. However, I wanted to understand why puts should give an error. I am not concerned if it prints on one line or not.


just Because with puts it will print each number on his line… instead of what the lesson want you to do so it see it like an error


That should be the only reason, as the code is not wrong…!


Yes, it the only one adn yes, your code is right…


I’m having the same problem too. I’m not sure if I have the coding right.

Here’s what I have:

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

odds.each do │x│
x *=2
print “#{x}”

I keep getting an “undefined local variable or method” message. I’ve been having issues with inputting the vertical line that separates the placeholder. I’m not sure how to put that in. Could that be my issue?


Never mind. I think I figured it out. I was using the wrong vertical line.