I have an object with some array items, now I have to calculate the length of all items. I got an idea to calculate these items, I declared count = 0
variable, then calculated these items length & added with count
variable.
var obj = {
item_1: ['item1', 'item2', 'item3', 'item4'],
item_2: ['item1', 'item2', 'item3', 'item4', 'item5'],
item_3: ['item1', 'item2', 'item3']
}
var count = 0;
Object.entries(obj).map(item => {
count += item[1].length
})
console.log(count)
My question is: how can I get this result without declaring calculate
variable? example: console.log(Object.entries(Obj)....?)