so i'm doing some excercises as practice, since i'm a beginner, and i stumble into this problem that i can't solve, would anybody be kind to give me a hand?
i would like to make a function that returns how many people is 18 or older, this is what i've been trying but i'm a bit confused..
const examplePeople = [
{ name: 'John', age: 15 },
{ name: 'Jane', age: 16 },
{ name: 'Jack', age: 25 },
{ name: 'Ana', age: 18 },
{ name: 'Raul', age: 23 },
{ name: 'Pedro', age: 17 }
];
function countLegalPeople(people) {
for (i= 0; i >= people["age"] ; i++){
if (people[i]["age"] >= 18) {
return people[i];
}
}
}
console.log(countLegalPeople(examplePeople));