Declare massive with objects and console log the different people according to their Age.
var people = [
{ firstname: 'Gosho', lastname: 'Petrov', age: 42 },
{ firstname: 'Bay', lastname: 'Ivan', age: 81 },
{ firstname: 'John', lastname: 'Doe', age: 42 },
{ firstname: 'Pesho', lastname: 'Pesho', age: 22 },
{ firstname: 'Asdf', lastname: 'Xyz', age: 81 },
{ firstname: 'Gosho', lastname: 'Gosho', age: 22 }
];
var counter=0;
for(i=0; i<people.lenght; i+=1) {
if (people[i].age === people[i+1].age) {
counter+=people[i];
}
}
How can i arrange the people by Age and console log them.