12.Loops and Iterators

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>
Why does it say I am incorrect? Been trying at it for 3 months. It says:

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

odds = [1, 2, 3, 4, 5]
odds.each do |odds|
odds *=2
print odds
end

<do not remove the three backticks above>
1 Like
odds.each do |x|
    if x % 2 != 0
        puts x * 2
    end
end

Without a link to the exercise we have no way to check this against the instructions. Please post a link. Thank you.

Hi, I struggled on this for a while also.
You have to make sure you are printing ‘x’ and not ‘odds’.
Hope this clears it up.

1 Like

Thanks this helped :slight_smile: