I have an object where Citems is an array of Object. Each object has status on or of and time.
{
Chapter: [
{
Cname: 'chapter 1',
Citems: [{status: 'on', time: 30},{status: 'on', time: 60}],
},
{
Cname: 'chapter 2',
Citems: [{status: 'on', time: 30},{status: 'off', time: 60}]
}
],
name: 'Something',
description: 'jfdgljfgdfjgldfkjglfd'
}
I want to generate an array or object from it that show total time for each status like below
{
on: 120,
off: 60
}
I tried with map and reduce but getting confused.