Im trying to aggrigate huge array of objects to single object, but my if statements replace each other:
const obj = [];
res.map((el) => {
if (el.resource.name === "FORM01" && el.name === "cost.ttl") {
obj[el.resource.name] = { [el.name]: el };
}
if ( el.resource.name === "FORM01" && el.name === "cost.use") {
obj[el.resource.name] = { [el.name]: el };
}
});
in result i wat add in obj[el.resource.name] = {} two fields "cost.ttl" and "cost.use".
Aucun commentaire:
Enregistrer un commentaire