I am currently facing a challenge in creating a multiple filter for multiple arrays without duplicating the nested array. I am working with vuejs and some plugins that are relying on the array, so my only option is to filter it without modifying it.
Using draggablevue, I have set up a list of arrays that can be sorted. My goal is to keep the main array intact and only filter the "inv" array based on name or code. I've tried using forEach, map, and filter methods, but haven't been able to find a solution online.
let invNameFilter = "chair";
let invCodeNameFilter = "1234";
let rooms = [
{
name: "Room 1.14",
inv: [
{
name: "chair",
inventoryCode: "1234"
},
{
name: "painting",
inventoryCode: "4321"
},
{
name: "table",
inventoryCode: "1234"
}
]
},
{
name: "Room 1.12",
inv: [
{
name: "table",
inventoryCode: "4321"
},
{
name: "chair",
inventoryCode: "4321"
}
]
}
];
let invNameFilter = "chair";
let invCodeNameFilter = "1234";
let rooms = [
{
name: "Room 1.14",
inv: [
{
name: "chair",
inventoryCode: "1234"
},
{
name: "table",
inventoryCode: "1234"
}
]
},
{
name: "Room 1.12",
inv: [
{
name: "chair",
inventoryCode: "4321"
}
]
}
];