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

Simon Goldman
Simon Goldman
1,028 Points

loops

cant figure out the first part on how to add those?

loop.rb
numbers = []

number = 0

loop do
  "number" + 1 = "numbers"
  if "numbers" = 3 
    break
  end
end

2 Answers

Since "numbers" is the array, in your loop; you need to use push

numbers.push(number)

Then add 1 to number

number + 1

In you "If" statement, you need to set a length limit to your array

if numbers.length >= 3

Make those changes, and it will pass

Amir Eskandari
Amir Eskandari
9,153 Points

Hi Simon,

You have a few things going on that are causing this challenge to fail - here are some hints to fix the issues:

1) In the challenge "number" and "numbers" are variables so you don't need to use quotation marks in your code.

2) Remember that "=" is an assignment operator, what you want to use for comparisons is "==".

3) Since "numbers" is an array you need to use a method to push values to it. https://ruby-doc.org/core-2.2.0/Array.html#method-i-push

4) In the problem you need to see when the length of numbers is == 3. This is another method for the Array class.

I hope that helps!