Intendi in questo modo ?
codice:const TRIBUTO1 = 1 const TRIBUTO2 = 2 const TRIBUTO4 = 4 const pagato = [ { tot: 10, tributo: TRIBUTO1 }, { tot: 4, tributo: TRIBUTO2 } ] const non_pagato = [ { tot: 10, tributo: TRIBUTO2 }, { tot: 3, tributo: TRIBUTO4 } ] const non_pagabile = [] const joinData = [...pagato, ...non_pagato, ...non_pagabile] // labels const labels = [...new Set(joinData.map(obj => obj['tributo']))] //total const total = joinData.reduce((sum, obj) => { return sum + obj['tot'] }, 0) console.log(`labels: ${labels}`) console.log(`total: ${total}`)

Rispondi quotando
