0
Hello I have an array of objects like this:
product: [
{ id: "1", name: "product 01" },
{ id: "2", name: "product 02" },
{ id: "3", name: "product 03" },
{ id: "4", name: "product 04" },
{ id: "5", name: "product 05" }
]
list: [ "1", "2", "5" ]
I would like a result similar to this, where it filters only the objects that are registered in the list by Id:
newArray: [
{ id: "1", name: "product 01" },
{ id: "2", name: "product 02" },
{ id: "5", name: "product 05" }
]
I think you have to use the filter with the map, but I’m having trouble making that union
did not understand the final result by
list: ["1", "2"]
and the result is 1, 2 and 5?– novic
It was recently edited: "[4] Improve syntax Highlighting" and included these extra values. However, I believe that for the result with ID: 5, it should be like this the
list: ['1', '2', '5']
.– thiagobraga
Avoid putting text as a photo because it makes it difficult to read on some devices. Copy and paste the output.
– Augusto Vasques
really, I’m sorry. The mistake was mine... I’ll fix
– Sarah Rodrigues
Now it made sense!
– Augusto Vasques