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

Michael Ross
Michael Ross
11,204 Points

I can't get passed a challenge - error, your code took too long to run

I don't see what is wrong with my code, taking too long to run according to the bummer error. Was working on this last night, same thing. Tried again this morning and it won't work. Really don't think this is anything to do with the code and that it is being caused by a server side issue or something at the Treehouse end.

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

2 Answers

You didn't increment your "count" value, so the count will be always less than 26 and your while loop will always be true. Thats why taking too long to run. Please try the following.

var count = 0;
while (count < 26 ) {
  document.write('print');
  count++;
}
Michael Ross
Michael Ross
11,204 Points

Sigh, I feel like an idiot. School boy error! Thanks for the heads up!