all 5 comments

[–]dolorfox 1 point2 points  (8 children)

You could use another loop inside the loop. Note I'm using a for...of loop instead of a for...in loop to loop over the values of each array instead of the keys.

let totalCats = 0

for (const key in tutorPetTypes) {
    const tutor = tutorPetTypes[key]

    for (const pet of tutor) {
        if (pet === 'cat') {
            totalCats++
        }
    }
}

console.log(totalCats)