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.
5 Comments
1
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you. https://accounts.binance.com/es-MX/register?ref=JHQQKNKN