I have an object array and am trying to add all values that don’t correspond with “c”. My current code is looking like this:
var example = [{a:1, b:2, c:3}, {a:4, b:5, c:6}, {a:7, b:8, c:9}]
function filtration (arr) {
var filteredsum = 0
for ( let i = 0; i < arr.length; i++) {
for ( let j = 0; j < arr[i].length; j++) {
for(let k = 0; k < arr[i][j].length && arr[i][j] !== “c”; k++)
filteredsum += arr[i][j]
}
}
return (filteredsum);
}
console.log(filtration(example));
The above is outputting 0, so I figure that instead of omitting the property “c” from the sum, it’s finding “c” and then omitting the entire object from the object array. Help?