I have a percentage component im working on and I need a way to go through a set of data and figure out how many items have the value audited set to true.
My data looks like this
{[{id: 1, audited: true},{id:2, audited: false}...]}
this is what Ive tried so far
const a = [];
let list = Object.values(items || {}).map((item) => {
console.log("ITEM", item);
if (item.audited === true) {
a.push(item);
}
return a;
});
My plan was to check the length of a and use that as my value. But what Ive done here is way overkill if I console out list its an array of all the items that pass the if test and the length of the array is the number of passes. All I need is the number of items in the object that have been audited. Any advice on how to clean this up would be very helpful I am new to coding so pls be kind.