title: Array inside Firebase ref not accessible
body: <p>Can anyone help me with this? </p>
  
  <p>The Variable <code>dwn</code> is defined inside the <code>foreach</code> but my Firebase DB does not update.</p>
  
  <p>The path is definitely correct. </p>
  
  <p>What's my mistake? </p>
  
  <p>Any help much appreciated!      </p>
  
  <pre><code> items.forEach(function (element) {
      console.log(dwn) // returns array like it should
      firebase.database().ref('vdemo/cities/' + city.toLowerCase() + "/categories/" + element.toLowerCase() + "/" + id).update({
         "img_paths": dwn // does to push to DB
          "category": element.toLowerCase() // defined and OK
      });
  
   });
  </code></pre>
  
  <p>The dwn array comes from here: </p>
  
  <pre><code>    dwn = [];
  
  
      function uploadImages (imageFile) {
  
          var storageRef = firebase.storage().ref(imageFile.name);
          var task = storageRef.put(imageFile);
          task.on('state_changed',
              function complete(){
                  var downloadURL = task.snapshot.downloadURL;
                  storageRef.getDownloadURL().then(function(url) {
                      dwn.push(url);    
                   });
  
              }
          );
  }
  </code></pre>
  
  <p>the array has this content: </p>
  
  <p><a href="https://i.stack.imgur.com/slKBT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/slKBT.png" alt="enter image description here"></a></p>