const objectTest = {
Shoes: [
{ id: 1, name: "xxx", image: "xxxxxx" },
{ id: 2, name: "yyy", image: "yyyyyy" },
],
Top: [
{ id: 1, name: "zzz", image: "zzzzzz" },
{ id: 2, name: "aaa", image: "aaaaaa" },
],
};
I know i can use the find method.
const item = objectTest.Shoes.find((p) => p.name === "xxx");
console.log(item); ///{id: 1, name: 'xxx', image: 'xxxxxx'}
but what if i don't know "xxx" belongs to the Shoes
group. How do I find "xxx"
and return { id: 1, name: "xxx", image: "xxxxxx" }