Skip to content

Instantly share code, notes, and snippets.

@geomago
Last active June 19, 2020 05:39
Show Gist options
  • Save geomago/e8a6e1471d8cde3b71de6f595de73a17 to your computer and use it in GitHub Desktop.
Save geomago/e8a6e1471d8cde3b71de6f595de73a17 to your computer and use it in GitHub Desktop.
find_cars
let maxPrice = cars.reduce( (prevPrice, current) => prevPrice < current.price ? current.price : prevPrice, 0);
let priceyCars = cars.filter( (car) => car.price==maxPrice );
// RESULT IS:
[{
id: 4,
make: "Bugatti",
model: "Chiron Pur Sport",
price: 3000000,
colour: "blue"
}, {
id: 8,
make: "Bugatti",
model: "Chiron Pur Sport",
price: 3000000,
colour: "red"
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment