Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142327

How to tally occurrences of an object key without using for loop JS

$
0
0

I have been given this function and I would like to know how to count the number of people who live in a city without using a for loop

function tallyPeopleInManchester(people) {


/* This function receives an array of people objects in for format:
[
  { name: 'Emmeline', lives: { country: 'UK', city: 'Manchester' }, age: 32 }
]

The function should return the number of people who live in the city of Manchester
*/

Viewing all articles
Browse latest Browse all 142327

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>