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
174,022 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!