Loops & Iterators


#1

Ok, I've repeatedly tried this exercise in different ways, and I keep getting error messages.

https://www.codecademy.com/courses/ruby-beginner-en-XYcN1/2/5?curriculum_id=5059f8619189a5000201fbcb#

I finally tried copying some code that I found in another message here, that worked for someone else.

And I get the error message:
"undefined method `*' for nil:NilClass"

Please help? I truly appreciate it!

odds = [1,3,5,7,9]
odds.each do x *= 2
    print x
end


#2

You got it in the example.
First you need to do:
odds.each do |x| and then later you do x *= 2

Click in the assignment down on Hint and you get:

odds.each do |placeholder|
  # Multiply placeholder by 2
  # Print out placeholder
end

#3

Thank you so much!

Cyn


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.