title: Javascript Nested for loop with ES6
body: <p>I guys, I have a nested for loop but I want to do it with an Array map/ES6 way but how does that work with nested forloops?</p>
  
  <pre><code>        for (var i = 0; i &lt; enemy.ships.length; i++) {
          for (var n = 0; n &lt; enemy.ships[i].location.length; n++) {
              if (obj.coordination == enemy.ships[i].location[n]) hit = true;
          }
      };
  </code></pre>
  
  <p>I know how to do it when it as not a forloop</p>
  
  <pre><code>players.map(function(player){if(player.id != socket.id) return enemy = player});
  </code></pre>
  
  <p>But I can't seem to understand how it should be with Array Maps or something else.</p>
  
  <p>I need to match the location of the ships location &amp; obj.coordination. This is the enemy.ships variable I need to check</p>
  
  <pre><code>    [ { type: 'Aircaft',
      size: 5,
      rekt: false,
      available: 1,
      location: [] },
    { type: 'Battleship',
      size: 4,
      rekt: false,
      available: 1,
      location: [ 77, 76, 75, 74 ] },
    { type: 'Destroyer',
      size: 3,
      rekt: false,
      available: 2,
      location: [ 54, 44, 34 ] },
    { type: 'Submarine',
      size: 3,
      rekt: false,
      available: 3,
      location: [] },
    { type: 'Patrolboat',
      size: 2,
      rekt: false,
      available: 4,
      location: [] } ]
  </code></pre>