Hello all,
I’m attempting to count the number of occurrences, but I just can’t figure it out. Been looking at map
, concat
, etc.
Here’s my most recent attempt:
render(){
const chartMoments = [
{
location: "Office",
mental: "Some",
environmental: "None"
}
// ...
]
const counter = () => {
chartMoments.map(moment => {
let noneCount = 0;
let aLittleCount = 0;
let someCount = 0;
let aLotCount = 0;
}
if(moment.environmental === 'None') {
noneCount++;
return noneCount
}
console.log(noneCount);
}
}
The problem is, I just can’t seem to increment them. It increments by 1 at that time, but does not store it and continue incrementing. I tried forEach
as well. But maybe I’m just getting lost in the order in which to do things?