JSFiddle - React, Tailwind, and code Playground
JavaScript
var foo = [
{"width":128.90663423245883,"height":160,"X":0,"Y":140},
{"width":277.0938568683375,"height":263,"X":128.90663423245883,"Y":37},
{"width":264.8267031014369,"height":261,"X":277.0938568683375,"Y":39},
{"width":229.14003389179788,"height":60,"X":264.8267031014369,"Y":240},
{"width":10.032771905968888,"height":177,"X":229.14003389179788,"Y":123}
];
function count(stack) {
var totWidth = 0;
stack.forEach(function(element) {
totWidth = totWidth+element.width;
});
return totWidth;
}
count(foo);