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.
(8) [Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1)]
0: ["Fulham v Arsenal"]
1: ["Crystal Palace v Southampton"]
2: ["Liverpool v Leeds United"]
3: ["West Ham United v Newcastle United"]
4: ["West Bromwich Albion v Leicester City"]
5: ["Tottenham v Everton"]
6: ["Sheffield United v Wolverhampton Wanderers"]
7: ["Brighton and Hove Albion v Chelsea"]
And then here's the one with posts made about them
0: ["Liverpool v Leeds United"]
1: ["Crystal Palace v Southampton"]
2: ["Crystal Palace v Southampton"]
So I basically want to make a final array like this:
(8) [Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1)]
0: ["Fulham v Arsenal", 0]
1: ["Crystal Palace v Southampton", 2]
2: ["Liverpool v Leeds United", 1]
3: ["West Ham United v Newcastle United", 0]
4: ["West Bromwich Albion v Leicester City", 0]
5: ["Tottenham v Everton", 0]
6: ["Sheffield United v Wolverhampton Wanderers", 0]
7: ["Brighton and Hove Albion v Chelsea", 0]
I am using this code to make a google bar chart. Here is the code that I have created so far.
var fixposts = [];
var posts = [];
var postsc = [];
var finala = [];
var y = 0;
var z = 0;
function getOccurrence(array, value) {
var count = 0;
array.forEach((v) => (v === value && count++));
return count;
}
<c:forEach items="${fixtures}" var="fix" varStatus="count">
fixposts.push(['<c:out value="${fix.home.teamName} v ${fix.away.teamName}"/>']);
</c:forEach>
console.log(fixposts);
<c:forEach items="${posts}" var="post" varStatus="count">
posts.push(['<c:out value="${post.fixture.home.teamName} v ${post.fixture.away.teamName}"/>']);
</c:forEach>
console.log(posts);
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.