What's the purpose of while loops in JavaScript?

1
Average: 1 (1 vote)
Reputation: 11
Asked 2 years ago.
325 View(s)
What's the purpose of while loops in JavaScript?

If you need to have variable within the parameters of a while loop and then change that variable to false within the loop to prevent it from being infinite, then what's the point of the "while" loop in the first place? Ex: var dog = true; while(dog){ console.log("Dog goes bark"); dog = false; }; That formatting obviously isn't great but you get the idea. What's the purpose of me changing the variable of dog to false when I need it to be true? Seems like while loops are a waste of time      

Delivery Time: 5 hours.
Question Category: Programming.
Anam Kamil
Reputation: 199
Free
Deliver in: 3 hours

Tutor Answer

You must be login to view answer.