I have a function which receives an array of person objects. The function should return the number of persons who lives in the city of Syndey. But, I am getting problem in returning a number of the person who lives in Sydney. What should I do? Anyone can help me, please?
This is the code that I have created:
function numberOfPeopleInSydney(person) {
people.forEach(function (arrayItem) {
if(arrayItem.lives.city==="Sydney")
return arrayItem.name;
});
}
forEachis a wrong choice, thisreturndoes nothing. AndtallyPeopleInSyndeymissesreturnstatementpersonbut callforEachonpeople...