I'm returning results from a firebase query. The result is an array of objects with different properties. It's for a car app that I'm making. Each object look like this
{
make: "make",
model: "model",
year: "year",
gas: "petrol",
mileage: "mileage",
images: {
image1: "url",
image2: "url"
}
}
I need to allow the users to be able to refine these results and I'm trying to come up with a robust solution
Problem: I need users to be able to refine results of a firebase query. The user will select different options for their refined search and so I need my function to be able to handle this
Where I'm up to
//Heres' how I planned to pass the refinement options
refinements = {
make: 'value',
model: 'value',
year: 'value'
}
//currentResults is an array of objects with different properties
const refineResults = (currentResults, refinements) => {
newResults = [];
for (int i = 0; i < currentResults.count; i++ ){
let currentResult = currentResult[i];
for(int i = 0; i < refinements.count; i++){
}
}
}
I know I'm not very far into this function but I'm not even sure if I'm approaching this the right way. I'm unsure of how to access the property value via a for loop, as refinement.[I] doesn't make sense to compare
I basically want to loop through my current results and if all the values I have in my refinements object are equal, then I want to add this result to my new result array.
Thanks for any input