title: Javascript callback within a while loop does not work?
body: <p>I'm trying to make an event driven while loop in javascript. Essentially it iterates through an array of values and makes a query during each iteration. Then, based on the result of the query it should either keep looping or stop and do something.</p>
  
  <p>I realize that you can't have callbacks in a while loop so I'm confused on how to even implement such a thing. Nested functions repeat themselves and that's not ideal.</p>
  
  <p>my loop code:</p>
  
  <pre><code>             var done = false;
               while(!done){
                  bridgeCheckRooms(send,function(reply){ //callback
                      console.log(tagArray[count]);
                      console.log(reply);
                      if(reply.success){
                          done = true;
                      } else {
                          count--;
                      }
                  });
              }
  </code></pre>