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!

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 Complete the Loop

sami thakur
sami thakur
970 Points

why does this keep crashing my browser???

im trying to take this code to see whats wrong with it, and whenever i use workspace, and open this code, it crashes my browser, wether it mozilla or firefox

var counter = 1;
while (10) {
    document.write("<p>Now in loop #" + counter + "</p>");
    counter + 1;

1 Answer

Patrik Horváth
Patrik Horváth
11,110 Points

while (counter < 10) and counter++; not counter +1 :)

your while is like while 10 = 10 xD its always TRUE so INFINITY LOOP :)

sami thakur
sami thakur
970 Points

oh ok xD, ty i was really confused for a bit