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

Florin Puia
Florin Puia
3,559 Points

Bummer: Your code took too long to run. - > It's annoying!

Bummer: Your code took too long to run. - > It's annoying! It takes to much to load 4 lines of code...

script.js
var count = 1;
while (count <= 26){
    document.write(document);
}
Florin Puia
Florin Puia
3,559 Points

It's work with that, sorry for the post,I forgot to add counter = counter + 1

var count = 1; while (count <= 26){ document.write('Something'); count = count + 1; }

1 Answer

Steven Parker
Steven Parker
231,248 Points

Without the line that increments "counter", the code would be an "infinite loop" which explains the error message about taking too long.

But with that line added, I would expect it to work properly.

Do you still have any problem?

Florin Puia
Florin Puia
3,559 Points

No, it works perfectly. Thank you!