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 trialCarl Smith
8,185 PointsCan't figure out this while loop
Note sure what I'm missing?
i = 0
while i > 5
i += 1
end
2 Answers
Jennifer Nordell
Treehouse TeacherYou just got the less than and greater than sign mixed up a bit! Try this:
i = 0
while i < 5
i += 1
end
Michael Hulet
47,913 PointsThis loop will never run. You initially set i
to 0
, but the loop will only run if i
is greater than 5
. My bet is that you meant less than. This will fix that:
i = 0
# Notice the reversed comparison sign
while i < 5
i += 1
end
Carl Smith
8,185 PointsThank you! The little things get me every time!
Jennifer Nordell
Treehouse TeacherTo be fair, it's rarely the giant logic flaws that get us, is it? It's always the misspelled variable or missing quotation mark, etc! That's why it's so nice that people hang out here on the forums. Some days it's nice just to have an extra set of eyes! :)
Carl Smith
8,185 PointsCarl Smith
8,185 PointsThank you! The little things get me every time!