I want to make a search that beside the first object searchs all other objects values inside it and returns in the array all those orders that matched and even if uppercase/lowercase don’t match:
Here is an random order: (not real data)
So that is my data I want to search, I have a function but that search only the first layer of the object and not for exampel the customer and vehilce object inside also Is not case sensitive so I would like to have that.
Here it is it:
const findIn = (arr, query) => {
let queryFormatted = query.toLowerCase();
return arr.filter((obj) =>
Object.keys(obj).some((key) => {
if (typeof obj[key] === 'string') {
return obj[key]
.toLowerCase()
.includes(queryFormatted);
}
return false;
})
);
};