Can you please show me the best way to process/ manipulate this array of hashes using javascript function chaining. I want to filter the data and return ONLY an array of hashes that contains data that in NOT all 0’s.
data = [
{name: "apple", data: [0, 0, 0]},
{name: "banana", data: [1, 0, 2]},
{name: "carrot", data: [0, 0, 0]},
{name: "pineapple", data: [0, 0, 3]},
]
//result after filtering
data = [
{name: "banana", data: [1, 0, 2]},
{name: "pineapple", data: [0, 0, 3]},
]
I was thinking something along the lines of
data.filter((hash,i) => {hash.data.every((elem,i)=> elem == 0);
.filterand use theeveryorsomemethod in the filtering function.carrotproperty instead ofdata? Is that supposed to be the name?