I'm trying to find clients' names from an array using the second array of client ids. I would try an old-school for loop, but I think in vuejs this is not the optimal solution.
This is my main array
clients = [
{id: "1", name: "Bob"},
{id: "2", name: "Mary"},
{id: "3", name: "John"},
{id: "4", name: "Petter"}
];
This is the array that contains only specific client ids
selectedClientsIds = [1, 2, 4];
console.log(clients.filter(({ id }) => selectedClientsIds.includes(+id))?.map(({ name }) => name));and check if displays an array of names matching theids in theselectedClientsIdsarray.