Ruby Ruby Loops Ruby Loops The Ruby Loop

loop do

NOt sure where to begin

loop.rb
numbers = [number]

number = 1

# write your loop here
loop do 

1 Answer

Tobias Helmrich
Tobias Helmrich
31,580 Points

Hey Kent,

you already started you loop. The first thing you should do now is check if the numbers array has 3 items in it so you can add a break statement and stop the loop when this evaluates to true, you can check this by using the length property of the numbers array.

After that you should push the current value of number to the numbers array and then increment the number variable by one.

And please set your number variable back to 0 as you shouldn't change the variable here but in the loop and empty your array as you will fill it in the loop as well.

numbers = []

number = 0

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

I hope that helps, if you have further questions just ask! :)