Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Loops Ruby Loops The Ruby Loop

2 Answers

You are doing a great job! However, you can't just say "number + 1", or Ruby will think you want the result of the number plus one. Instead, you have to do "number += 1". Second, there is no "===" operator in Ruby. That's only for JavaScript. You'll have to use the "==" operator. Lastly, I don't know why you did "numbers == numbers[2]", but you should get the length, like this: "numbers.count" or you also could do: "numbers.length", and see if it is equal to three. The code:

numbers = []

number = 0

# write your loop here
loop do
  number += 1
  numbers.push(number)
  if numbers.count == 3
    break
  end
end

Hope that helps! :dizzy:

Close. Try this:

loop do
  numbers.push(number)
  number += 1 
  if numbers.length >= 3
    break
  end
end