JSFiddle - React, Tailwind, and code Playground

by Pankaj Kargirwar

JavaScript

const o = {
  "line": [{
    "id": "staff-0",
    "serial": 0,
    "clef": "treble",
    "bars": [],
    "overflow": []
  }, {
    "id": "staff-1",
    "serial": 1,
    "clef": "bass",
    "bars": [],
    "overflow": []
  }, {
    "id": "staff-2",
    "serial": 2,
    "clef": "alto",
    "bars": [],
    "overflow": []
  }],
  "maxBarLengths": [3]
}

let tot = o.line.map(s => s.bars.length + s.overflow.length).reduce((a, c) => a + c, 0);
console.log(tot);