At the end of exercise 27, Zed suggests “playing around” with chaining to (among other things), average the pet ages. I have been trying to do this, but have not yet cracked it. I tried writing a little “divide” function, and chaining it:

const divide = (num, arr) => {

return num / arr.length

}

let totalAges = pets.map(pet => pet.age)

.reduce((acc, age) => acc += age)

.divide(totalAges, pets)

But I get the following error:

ReferenceError: totalAges is not defined

I intuitively knew this was off somehow, but for the life of me I cannot figure this out. Any ideas?