Within my array of objects, I am performing a search
let arr = [
{ name:"string 1", arrayWithvalue:"1,2", other: "that" },
{ name:"string 2", arrayWithvalue:"2", other: "that" },
{ name:"string 2", arrayWithvalue:"2,3", other: "that" },
{ name:"string 2", arrayWithvalue:"4,5", other: "that" },
{ name:"string 2", arrayWithvalue:"4", other: "that" },
];
var item = arr.find(item => item.arrayWithvalue === '4');
console.log(item)
The desired outcome is to obtain an array containing these two rows
{ name:"string 2", arrayWithvalue:"4,5", other: "that" },
{ name:"string 2", arrayWithvalue:"4", other: "that" }
However, only one row is being returned which is the first match.
{ name:"string 2", arrayWithvalue:"4", other: "that" }
I prefer not to rely on external libraries for a solution. Is there a way to capture all the matches that satisfy the set criteria?