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 trial

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a while Loop

omar othman
omar othman
7,441 Points

why does the challenge keeps posting this error when I finish it "Bummer! Your code took too long to run."?

is there something wrong with the code?

script.js
var count = 0;
while(count<26){
  document.write();
}

4 Answers

Hi Omar,

Your code is stuck in a never ending loop. You are telling it to do something while count is less than 26, but count is always 0 since nothing gets added to it. So it will always be 0 and the code will run and run since it never hits 26. Try to increment count somewhere in your while-loop.

count++
omar othman
omar othman
7,441 Points

oh, right, forgot that, thank you!

No problem. :)

jason chan
jason chan
31,009 Points
count++;

you need to increment your while loop each loop.

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

This typically happens when you're running an infinite loop through the challenge. What you need to do is give the code a way to break out from the loop.

var count = 0;
while(count<26){
  document.write();
 count++;
}

You can do this with the increment operator. Now the while loop will count the variable 25 times and stop when the value of count is not longer less than 26.

Good luck. :-)

omar othman
omar othman
7,441 Points

thanks everyone!