How do I complete this code?
Racking my brains here. Appreciate any help.
numbers =  number = 0 # write your loop here loop do print "Enter a number. " numbers = number number = gets.chomp.to_i if number = (+ 1, 0) elsif number = (+ 1, 1) else number = (+ 1, 2) break end end
Jennifer NordellTreehouse Staff
Hi there! I can see that you've worked on this quite a bit. I would advise going back and reviewing arrays and how we add and manipulate them. But here's my solution and I'll walk you through it.
numbers =  number = 0 # write your loop here loop do numbers.push(number) number += 1 if numbers.count >= 3 break end end
The first part is set up for us by Treehouse. It contains an empty array named
numbers and a variable named
number with an initial value of 0. We start our loop. The first thing we do is add the number to the
numbers array. So at this point 0 is put into the array. Then we increment the number variable to 1. Next we check to make sure we don't have 3 or more numbers in the array. If we do, we break the loop. The end result will be that your numbers array will contain the values 0, 1, and 2.
Hope this helps!