title: How to make a request and build a URL with array items in javascript
body: <p>The commented out code works but only for a single team, I'm trying to iterate over all of the teamIDs in order to get their roster players IDs and store them within the array playerList.</p>
  
  <p>The part I'm not sure how to deal with is actually making the request to the link and iterating over each object within the teamID array and using those values in the link im requesting from.</p>
  
  <pre><code>var teamID = [];
  var playerList = [];
  
  d3.json('https://statsapi.web.nhl.com/api/v1/teams', function(data) {
      for (i=0; i &lt; 31; i++) {
          teamID.push(data.teams[i].id);
    }
  });
  
  console.log(teamID);
  
  // d3.json('https://statsapi.web.nhl.com/api/v1/teams/1/?expand=team.roster', function(data) {
  //   for (k=teamID[0]; k &lt; teamID.length, k++) {
  //
  //     for (i=0; i &lt; data.teams[0].roster.roster.length; i++) {
  //       playerList.push(data.teams[0].roster.roster[i].person.id);
  //
  //     }}
  // });
  
  //console.log(playerList);
  
  var item;
  
  for (i=0; i &lt; teamID.length; i++) {
    for (item in teamID[i]) {
      d3.json('https://statsapi.web.nhl.com/api/v1/teams/'+item+'/?expand=team.roster', function(data) {
        for (k=0; k &lt; data.teams[i].roster.roster.length; k++) {
          playerList.push(data.teams[i].roster.roster[k].person.id);
        }
      })
    }
  };
  
  console.log(playerList);
  </code></pre>