title: How to use fetch within a for-loop, wait for results and then console.log it
body: <p>i have this problem: i want to make multiple fetch calls within a for-loop. The number of calls depend on the user input (in my example i have three). How can i make it loop through all the fetch requests and then console.log the number off calls?</p>
  
  <p>function getPosts(){</p>
  
  <pre><code>  let url = ["https://www.freecodecamp.org", "https://www.test.de/, http://www.test2.com"];
    let array = new Array;
  
    for (let i = 0; i &lt; url.length; i++) {
      console.log(url[i]);
      fetch(url[i])
      .then(res =&gt; {return res.text(); })
      .then(res =&gt; {
              let reg = /\&lt;meta name="description" content\=\"(.+?)\"/;
              res = res.match(reg);
              array.push(res);
              console.log(res);
            }
      )
      .catch(status, err =&gt; {return console.log(status, err);})
    }
    console.log (array.length);
    }
  </code></pre>
  
  <p>It console.logs 0 instead of 3, cause it doesn't wait for all the promises to be resolved. How can i make it to console.log 3?
  If you know a solution, please help me out.</p>