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 trialSophie Leonetti
Courses Plus Student 6,561 PointsWhat am I doing wrong ?
In the Ruby challenge " Using a while loop, increment the value of the variable i as long as it remains less than 5"
i = 0 while i < 5 i =+ 1 end
It says "Your code took too long to run" What's wrong with my answer?
Thanks
Sophie Leonetti
Courses Plus Student 6,561 PointsThanks :-)
Michael Hall
Courses Plus Student 30,909 PointsBill McKinnon, You added your answer as a comment. It's a little confusing, but if you look a little lower on the page there is a "add an answer" section. You have to add your answer here to get your point
billmckinnon
14,247 PointsAhh!! Thank you Michael!
Michael Hall
Courses Plus Student 30,909 Pointsno problem, I gave you an upvote for your answer
1 Answer
billmckinnon
14,247 PointsCorrect answer:
i = 0
while i < 5
i += 1
end
You mistyped the += operator. Your code would be more readable and you may pick up on these types of mistakes easier if you format and indent your code as well.
billmckinnon
14,247 PointsIf my answer was useful to you please vote it as best answer :) Thank you!
Brandon McClelland
4,645 PointsBrandon McClelland
4,645 PointsYou've got =+ instead of +=
Add AND assignment operator, adds right operand to the left operand and assign the result to left operand. c += a is equivalent to c = c + a