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
Aliayub Ali
3,495 PointsHelp with this question guys.
How do I prevent myself from getting an infinite loop, when I am doing one of the while do and for loops, what is the right way or the code line, that lets me know that this code will be endless or infinite, how do I know that.
1 Answer
<noob />
17,063 PointsHi!, that depends on what u want to accomplish. if ur in a do while loop, the code will always run once and keep running if the user have not entered or did the thing u wanted him to do. for example : i have a party today and i want to invite some people to my party
do{ const name = prompt(“enter your name”) } while( name == null )
in this code i keep asking the user to prompt until he entered a name