Open eric-do opened 2 years ago
Also, in your Reviews component you can probably make use of .reduce there too.
Original
const filter = Object.keys(filters);
let filterExists = false;
let filterArray = [];
let results = [];
let object = {};
for (let value of filter) {
if (filters[value] === true) {
filterArray.push(value);
filterExists = true;
}
}
Modified (not tested)
const filterArray = Object.entries((filterArray, [key, value]) => {
if (filters[value] === true) {
filterArray.push(value)
}
return filterArray;
}, [])
None of these changes are required but it's good to get proficient with array methods.
https://github.com/fec-rogue/atelier-rogue/blob/2f1409eff5871efd01358d4d317c592904e689c8/client/src/components/reviews/Relevance.jsx#L26
Nothing wrong with this code, but try to use the array methods that are made for their purposes, to show proficiency with them.
We should be using
.reduce
here instead of.forEach
Instead of:
Do: