Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?

Hello.

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 :)