title: Create and store different arrays in each object
body: <p>I'm new programming in JS and I'm designing an application to search for sites by county (it would be something like state) and municipality (Counties).</p>
  <p>From the data I obtain through an API I get the following results.</p>
  <p><a href="https://i.stack.imgur.com/0027B.png" rel="nofollow noreferrer">data from API </a></p>
  <p>As you can see there are some counties that are repeated and what I am interested in is to assign the county in an object and within that object create an array with its municipalities.</p>
  <p>At the moment I have removed the repeated counties, but I cannot put each object with its municipalities.</p>
  <p><a href="https://i.stack.imgur.com/Miiu9.png" rel="nofollow noreferrer">API to array</a></p>
  <p>My code is the following basically what I do here is to remove the repeated data from the counties.</p>
  <p>(variable <strong>data</strong> is the values from API picture 1)</p>
  <pre><code>for(let i=0; i&lt; data.length; i++)
  {
      let found = false;
      for (var j=0; j&lt;array.length; j++) {
          if (data[i].nom_comarca == array[j].comarca) {
              municipis.push(data[i].municipi)
              found = true;
              break;
          }
      }
      if(!found) // If not find we add into Array
      {
          array.push({
              comarca : data[i].nom_comarca,
              municipis: municipis
          })
          //municipis = [];
      }
  }
  </code></pre>
  <p>Thanks for all really!!</p>