0👍
I Might misunderstood the question, but I’ll try to answer what I did understand from your question.
What you can do is to use a filter
function plus a map
function.
model.plots.value = plots
// 1. filter out all plots that have no values
// please note, that if they have 0 as value, they will also be
// filtered out with your if condition.
.filter((plot) => plot.length && plot.width && plot.acreage)
// 2. map the current structure to the final structure.
.map((plot) => ({
// return your target structure here...
}))
Maybe you can update your question a bit with more code, that the context can be understood better. Because it is not obvious, because at the top you have model.plot
and in the second example you use model.plots
.
Source:stackexchange.com