I have a Vuex store which has a roster object. The roster object has an array of subteam objects. Each subteam object has an array of position objects. How do I count the total positions?
See the following getter:
totalPositions : function (state) {
let reducer = (accumulator, subteam) => accumulator + subteam.positions.length;
return state.roster.subteams.reduce(reducer);
}
When I log the result, I get something like:
"[object Object]33010600000000000000000000000000000"
The digits in the string closely resemble the actual lengths of the position arrays, but not exactly. I tried using parseInt (even though array.length should be an integer):
let reducer = (accumulator, subteam) => {
return accumulator + parseInt(subteam.positions.length,10);
};
It didn't help.