Hi, this is the solution for the homework question asked that is using only reduce to give the o/p of the first names of the people whose age is. < 30:
const arr = [
{ firstname: "Akshay", age: 26 },
{ firstname: "Donald", age: 56 },
{ firstname: "deepika", age: 26 },
];
const op = arr.reduce(function (acc, curr) {
if (curr.age < 30) {
acc.push(curr.firstname);
}
return acc;
}, []);
// we pass empty array as the inital value as accumulator and then push the
firstnames whose age < 30
console.log(op);
https://www.youtube.com/watch?v=zdp0zrpKzIE -> link to the video.
Thanks,
Anush.
