I have an array I have created inside of my component which combines a name and then another array with the number of times the name has been selected.
I'm struggling to convert the second array (within the first array) into a number or say something like Array.length.
Here is the logged out Array:
0: (2) ["Elliott Lester", Array(4)]
1: (2) ["Frank Miller", Array(3)]
2: (2) ["Adam McKay", Array(3)]
3: (2) ["Zola", Array(3)]
4: (2) ["Saul Metzstein", Array(3)]
5: (2) ["Baltasar Kormákur", Array(2)]
6: (2) ["J.A. Bayona", Array(2)]
7: (2) ["Katsuhiro Ôtomo", Array(1)]
8: (2) ["Darren Aronofsky", Array(1)]
9: (2) ["Alex Proyas", Array(1)]
10: (2) ["Andy Humphries", Array(1)]
11: (2) ["Ken Loach", Array(1)]
12: (2) ["Francis Ford Coppola", Array(1)]
13: (2) ["Andrew Stanton", Array(1)]
14: (2) ["Danny Boyle", Array(1)]
length: 15
__proto__: Array(0)
//component code
let data = groupBy(this.mom,'name')
this.data = Object.keys(data);
this.values = Object.keys(data).map(key => data[key]);
const voting = {};
this.data.forEach((key, idx) => voting[key] = this.values[idx])
let votesresults = [];
for (var player in voting) {
votesresults.push([player, voting[player]]);
}
votesresults.sort(function(a,b){
return b[1].length - a[1.].length;
});
this.values = votesresults;
console.log(votesresults);
I'd like to display the array(s) as:
Elliott Lester, 4 - but can't seem to figure out how. Any hekp would be greatly appreciated.
I've tried binding length to the array which is called values so:
{{ values[i].length }} - this just displays the length of the entire array.
{{ values[i].Array.length }} - knew this wouldn't work, but gave it a try anyway, because I was out of ideas!
this.array.forEach(e => { e.arrayInside.forEach(c=>{ //some logic }) })