I want to get the total of all items in object with array. for example
const obj = {
one: [1, 4],
two: [4, 6]
}
I should get total of 4.
I tried
const obj = {
one: [1, 4],
two: [4, 6]
}
let total = 0;
const objKeys = Object.keys(obj);
for (let index = 0; index < objKeys.length; index++) {
total += obj[objKeys[index]].length
}
console.log(total);
Is there a simpler way of doing this?