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 trialKent Drummond
8,309 Pointsloop do
NOt sure where to begin
numbers = [number]
number = 1
# write your loop here
loop do
1 Answer
Tobias Helmrich
31,603 PointsHey 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! :)