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?

numbers = []

number = 0

# write your loop here

2 Answers

Jeremy Hill
Jeremy Hill
24,306 Points

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