title: Javascript check how many times an item appears in a list and then add the lists together
body: <p>I am trying to get check how many times a fixture has a post made about it, I have a list of all the teams and then all the teams which have fixtures.
  Here is a list of the fixtures.</p>
  <pre><code>(8) [Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1)]
  0: [&quot;Fulham v Arsenal&quot;]
  1: [&quot;Crystal Palace v Southampton&quot;]
  2: [&quot;Liverpool v Leeds United&quot;]
  3: [&quot;West Ham United v Newcastle United&quot;]
  4: [&quot;West Bromwich Albion v Leicester City&quot;]
  5: [&quot;Tottenham v Everton&quot;]
  6: [&quot;Sheffield United v Wolverhampton Wanderers&quot;]
  7: [&quot;Brighton and Hove Albion v Chelsea&quot;]
  </code></pre>
  <p>And then here's the one with posts made about them</p>
  <pre><code>0: [&quot;Liverpool v Leeds United&quot;]
  1: [&quot;Crystal Palace v Southampton&quot;]
  2: [&quot;Crystal Palace v Southampton&quot;]
  </code></pre>
  <p>So I basically want to make a final array like this:</p>
  <pre><code> (8) [Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1)]
  0: [&quot;Fulham v Arsenal&quot;, 0]
  1: [&quot;Crystal Palace v Southampton&quot;, 2]
  2: [&quot;Liverpool v Leeds United&quot;, 1]
  3: [&quot;West Ham United v Newcastle United&quot;, 0]
  4: [&quot;West Bromwich Albion v Leicester City&quot;, 0]
  5: [&quot;Tottenham v Everton&quot;, 0]
  6: [&quot;Sheffield United v Wolverhampton Wanderers&quot;, 0]
  7: [&quot;Brighton and Hove Albion v Chelsea&quot;, 0]
  </code></pre>
  <p>I am using this code to make a google bar chart. Here is the code that I have created so far.</p>
  <pre><code>    var fixposts = [];
  var posts = [];
  var postsc = [];
  var finala = [];
  var y = 0;
  var z = 0;
  
  function getOccurrence(array, value) {
      var count = 0;
      array.forEach((v) =&gt; (v === value &amp;&amp; count++));
      return count;
  }
  &lt;c:forEach items=&quot;${fixtures}&quot; var=&quot;fix&quot; varStatus=&quot;count&quot;&gt; 
  fixposts.push(['&lt;c:out value=&quot;${fix.home.teamName} v ${fix.away.teamName}&quot;/&gt;']);
  &lt;/c:forEach&gt;
  console.log(fixposts);
  &lt;c:forEach items=&quot;${posts}&quot; var=&quot;post&quot; varStatus=&quot;count&quot;&gt; 
  posts.push(['&lt;c:out value=&quot;${post.fixture.home.teamName} v ${post.fixture.away.teamName}&quot;/&gt;']);
  &lt;/c:forEach&gt;
  
  console.log(posts);
  </code></pre>
  <p>The fixposts array is all of the teams that have fixtures that week and the posts is the teams which have a fixture that week and a post made about them. How would I then combine both of these so I can have a single array with all fixtures and either 0 or how many posts were made about them?
  Thank you.</p>