title: Javascript while loop where condition is a promise
body: <p>Is it possible to make a native JavaScript <code>while</code> loop where the condition is a promise? </p>
  
  <p>Edit:
  What I'm trying to do is implement a check before uploading a file to firebase storage, to see if a file with the same name already exists in the firebase storage. If there is already a file with the same name then add a random suffix and check again. </p>
  
  <pre><code>var storageRef = firebase.storage().ref().child(fileName);
  
  while(storageRef.getDownloadURL()) {
      // create random number in between 0 and 100
      var random = Math.floor((Math.random() * 100) + 1);    
      storageRef = firebase.storage().ref().child(fileName + random);
  }
  
  storageRef.put(file);
  </code></pre>