title: What is the effecient way of returning a promise in for loop in Javascript
body: <p>I have a function that return a promise after a for-loop in javascript, and since i am new to promise and async-await i was wondering if this the efficient way of returning a promise in iteration process. Here is the snippet</p>
  
  <pre><code>function addImagesToCanvas(urls){
  
      return new Promise(resolve =&gt; {
  
         for(url of urls){
  
            loadImage(url).then(img_element =&gt;{
  
                addImageToCanvas(img_element);
            });
         }
  
         resolve();
      });
  
  }
  
  function displayCanvas(){
  
        $.ajax({
               ....
               success: function(response){
  
                     urls = JSON.Parse(response);
                     addImagesToCanvas(urls).then(() =&gt; {
  
                          //..Do something
                     });
  
               }
        });
  
  }
  
  Is there a way of re-writting the above code with **async/await** ? Thanks for the comments
  </code></pre>