I am working with an array of objects that require me to analyze two properties in order to calculate a value.
let data = [
{
NodeId: "9837f279",
NodeName: "Node1",
summary: {
current: 50,
limit: 75
}
}, {
NodeId: "4189f279",
NodeName: "Node2",
summary: {
current: 60,
limit: 100
}
}, {
NodeId: "9837f279",
NodeName: "Node1",
summary: {
current: 30,
limit: 75
}
}
]
In this scenario, I want to sum up the values from all nodes:
(50 + 60 + 30) / (75 + 100 + 75) = summary.current / summary.limit
What would be the JavaScript solution for calculating this?