title: Compare two arrays and count incidents
body: <p>I have two array</p>
  
  <pre><code>$array1=('18753933','18753933','18771982')
  $array2=('18753933','18771982')
  
  </code></pre>
  
  <p>I'm going through each one to compare the values that are the same in each array </p>
  
  <pre><code>var contarArticulosCargados=0;
  
  for(var $i=0;$i&lt;$array1.length;$i++) {
      for(var $j=0;$j&lt;$array2.length;$j++) {
          if($array1[$i]===$array[$j]) {
              countArticulosCargados++;
          }
      }
  }
  
  console.log(countArticlesLoaded);
  </code></pre>
  
  <p>This example that I have put in my code works well, that is to say, I am doing the comparison and it works without problem.</p>
  
  <p>What do I want to do? (It's what I have no idea how to do)</p>
  
  <p>As you can see in <code>$array1</code> is the value 18753933 and in <code>$array2</code> is also the value <code>18753933</code>.</p>
  
  <p>What I want is that when the value is repeated this is counted, in the <code>$array1</code> the value <code>18753933</code> is <code>2</code> times and the value <code>18771982</code> is <code>1</code> time.</p>
  
  <p>I want to see something like this:</p>
  
  <pre><code>18753933 repeats: 2 
  18771982 is repeated: 1
  </code></pre>
  
  <p>could you give me an idea of what I'm missing? I always find it hard to make comparisons between arrays. Thank you.</p>