I'm struggling to extract specific cars from a list in Javascript.
Here is the list of cars:
const cars = [
{
id: 1,
brand: "Mercedes Benz",
properties: [
{
property: "Mechanical",
value: 2,
},
{
property: "Chemical",
value: 2,
},
{
property: "Pressure",
value: 3,
}],
},
{
id: 2,
brand: "BMW",
properties: [
{
property: "Mechanical",
value: 5,
},
{
property: "Chemical",
value: 3,
},
{
property: "Pressure",
value: 6,
}],
}
]
To achieve this, I am looking for cars that have a particular property with a value greater than X
For example, if I specify 'Mechanical' as the property and '3' as the value, I should get back the entire object with id 2
Does anyone have any suggestions? This has been quite challenging for me
Apologies for the formatting issues with the code, I'm having trouble posting it formatted on StackOverflow.
Tip: Try pasting it into a Node REPL ;)
Thank you in advance