ortunado
ortunado
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
You could even do reduce and just build the options within there.
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
You can use || instead for some of those conditions.
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
Basically, when you have selectedFloor, do not take in account selectedDoor for the options.
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
Well, that's expected. You need to adjust the logic then, to take in account the previous condition e.g floor for door.
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
That means you have selectedBlock, selectedDoor still something else than falsy
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
You can as well, use reduce to only have single iteration.
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
const stairs = [...new Set(filtered.map(({ stair }) => stair))]
const stairs = [...new Set(filtered.map(({ stair }) => stair))]
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
keeping your order of - Block, Stair, Floor, Door
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
this should handle that the value is not there
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
floor add yourself
35 replies
RReactiflux
Created by Sniberb on 3/27/2025 in #help-js
snowberb – 13-45 Mar 27
const filtered = arr.filter((unit) => {
return (
(!selectedBlock || unit.block === selectedBlock) &&
(!selectedStairs || unit.stair === selectedStairs) &&
(!selectedDoor || unit.door === selectedDoor)
);
});
const filtered = arr.filter((unit) => {
return (
(!selectedBlock || unit.block === selectedBlock) &&
(!selectedStairs || unit.stair === selectedStairs) &&
(!selectedDoor || unit.door === selectedDoor)
);
});
35 replies