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

Ling Hoe Chew
Ling Hoe Chew
122 Points

Using the loop construct, add the current value of number to the numbers array. Inside of the loop, add 1 to the number

i dont really understand the question?

loop.rb
numbers = []

number = 0

# write your loop here

2 Answers

It wants you to start a loop and then add the current value of the variable 'number' to the array then it wants you to increment the 'number' variable before the end of the loop. So your number should have incremented three times having the value of 3 afterwards and your numbers[] array should have a total of three indices which is supposed to be what breaks you out of your loop.

start loop... add current value of number to array[] increment number variable check to see if number of indices equals 3 IF not loop through again. if indices equals 3 BREAK out of loop

I hope this helps

Where in the video does it discuss how to add a number to an array? I've seen nothing about the shovel operator