const petsLists = [
{ name: 'Dog', age: 4 },
{ name: 'Cat', age: 6 },
{ name: 'Finches', age: 8 },
{ name: 'Hamster', age: 1 },
{ name: 'Squirrel', age: 2 },
{ name: 'Betta Fish', age: 0.5 },
];
const total = petsLists.reduce(function(sum, element){
return sum + element.age;
});
console.log(total);
This Pen doesn't use any external CSS resources.