I have one array with a list of all cars, as follows :
const allCars = [
{id: 1, listID: 1, name: "Car 1", chassis: "000000000"},
{id: 2, listID: 2, name: "Car 2", chassis: "111111111"},
{id: 3, listID: 1, name: "Car 3", chassis: "222222222"},
{id: 4, listID: 1, name: "Car 4", chassis: "333333333"}
];
and I have some of those cars in the shopping cart, as follows :
const carsInCart = [
{carID: 1, listID: 1, offer: 488},
{carID: 2, listID: 2, offer: 786},
]
Is there any way to filter throught allCars and return only those which are in carsInCart, and return only chassis from allCars and offer from carsInCart?
Thus, what I want is something like this :
const result = [
{chassis: 000000000, offer: 488},
{chassis: 111111111, offer: 786}
]
constwherevar, orletwould be more appropriate. Using them as you have implies that you might have some confusion as to where to use each of these statements