Quantcast
Channel: User Just code - Stack Overflow
Viewing all articles
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?

$
0
0

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 all articles
Browse latest Browse all 41

Trending Articles



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