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 trialAgnes Caringal
6,239 PointsWhile loop codes... what's wrong with my codes
did i forgot something? thanks
var count = 0;
while (count > 26) {
document.write("<p>Loop Numbers # "+ count + </p>");
count += 1;
}
6 Answers
Agnes Caringal
6,239 Pointsguys i already solved...it goes like this
var count = 0;
while (count < 26) { document.write(count + ''); count += 1; }
miguelcastro2
Courses Plus Student 6,573 PointsThis code will not run since count is equal to 0 and the while loop will only run if count is greater than 26.
Agnes Caringal
6,239 Pointsmiguelcastro2 i made it
Jacob Mishkin
23,118 PointsYour really close on this. There are a couple of things you need to change.
change the greater than sign to equal that count is less than "<" 26 this way the loop with exit at 26, because its asking for the loop to run up to 26 times,
in the document.write() the only parameter needed is the count var. nothing else.
so document.write(count);
everything else looks good though. I hope this helps.
ronanmcguire
4,497 Pointsvar count = 0;
while (count < 27) {
document.write(count);
count =+1;
}
I keep getting the error message " Bummer! Your code took too long to run."
Is there something wrong with the code?
BTW, shouldn't it be
while (count < 27) {
as the loop needs to run 26 times, which is < 27?
ronanmcguire
4,497 PointsJust realised I put
count =+ 1;
instead of
count += 1;
live and learn!
Agnes Caringal
6,239 Pointssolved already..check my previous comment...thanks Jacob Mishkin :)
Jacob Mishkin
23,118 PointsI did, and awesome job!! I voted your answer as the best answer, there is nothing better than solving your own problems. Happy coding.
Agnes Caringal
6,239 Pointsthank you so much Jacob Mishkin :) :)
Jacob Mishkin
23,118 PointsNot a problem.