I've written a method to calculate the number of objects in an array which have 'enabled' set to 'true'.
I'm adding 1 to counter each time it finds an object in my array which has 'enabled' set to 'true'.
How could I achieve this without using 'counter' variable and using reduce or filter instead??
Here's my code:
function getCount() {
const arr =[[{ "enabled": true }], [{ "enabled": false}, {"enabled": true}]];
var count = 0;
arr.forEach(function(ar){
ar.forEach(function(obj){
if(obj.enabled) {
count++;
}
})
});
return count;
}
obj.seatMapAvailable? Did you meanobj.enabled?