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 trialDaniel Cunningham
21,109 PointsChallenge Question Typo?
Challenge is "Using the loop construct, add the current value of number to the numbers array. Inside of the loop, add 1 to the number variable. If the numbers array has more than 3 items, use the break keyword to exit the loop. "
However, if you put the conditional "numbers.count > 3" into the challenge, the challenge tells you "the length of the array is not 3. When you put numbers.count == 3, the test passes.
I think the question should be modified to "If the numbers array has 3 items, use the break keyword to exit to loop."
numbers = []
number = 0
loop do
numbers.push(number)
number +=1
if numbers.count > 3
break
end
end
# write your loop here
1 Answer
Jamie Perlmutter
10,955 PointsYeah I had the same issue with that, it's actually wanting you to go to 4 before breaking out. Try switching it to > 4 and that should do the trick.
Daniel Cunningham
21,109 PointsDaniel Cunningham
21,109 PointsHm, in my case, numbers.count == 3 passed, so maybe we got a different question? Thanks for sharing your experience!