Consider I have an array-object which looks like this
const options = [{ label: "" }, { label: "123" }]
Now, I want to filter it and remove object which have label
value equal to ""
and then add order property equivalent to index to those object in an array having some value for label
I am able to do with combination of lodash filter and map but I was thinking if I could do it in a better way (probably using just filter?)
const options = _.filter(options, "label").map(
(option, position) => {
return {
...option,
order: position
}
}
)