Quantcast
Viewing latest article 23
Browse Latest Browse All 41

Answer by Just code for How to rename properties in objects that are in an array. What is the right way to solve the task?

You can use map

The map() method creates a new array with the results of calling a provided function on every element in the calling array.

const graphicDetails =  [{"hour": 0,"businessOperationPlansTotalDemand": 8.201753196882908,"employeesCount": 0,"businessOperationPlans": [{"name": "operation0","value": 5.999355066255491    }, ]  },  {"hour": 1,"businessOperationPlansTotalDemand": 7.450044665662842,"employeesCount": 3,"businessOperationPlans": []  }];const newData = graphicDetails.map(a=>{return {x:a.hour,y:a.businessOperationPlansTotalDemand,businessOperationPlans:a.businessOperationPlans };})console.log(newData);

Viewing latest article 23
Browse Latest Browse All 41

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>