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 Tracking Data Using Objects The Student Record Search Challenge

Maksim Kazlouski
Maksim Kazlouski
8,986 Points

How to interrupt endless loop?


I was working on my solution to this lesson task step-by-step and come across bug - endless loop. Code looked like this:

while(){ prompt('Something'); }

So when i refreshed page with the project i wasn't able to stop execution of JS code. Question is: how to abort execution of JS code on web page (especially when constant prompt message appears?

I don't normally recommend StackOverflow since I find it typically too technical to understand, but most of the answers in this thread seem less daunting: http://stackoverflow.com/questions/905322/how-do-you-stop-an-infinite-loop-in-javascript But the short of it is, according to them, no you can't put abort the loop other than typically closing the tab (or sometimes the whole browser!).

1 Answer

Grace Kelly
Grace Kelly
33,990 Points

This might be of some use to you :)