Comment renvoyer des valeurs spécifiques d'un filtre en javascript

//link
// https://stackoverflow.com/questions/57861821/how-to-return-specific-values-from-a-filter-in-javascript

var animals = [
 {id:1, name:"cat"}, 
 {id:2, name:"dog"}, 
 {id:3, name:"fish"}
];

var selected = [1,2];

var selectedAnimals = animals.filter(animal => selected.includes(animal.id));

console.log(selectedAnimals);
Disgusted Dragonfly