Author: Anush Narayanan

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,…

Read More

Hi all, I also figured out another way out to write the code for printing 1,2,3,4,5 in 1,2,3,4,5 seconds respectively without using let and only using var. this is regarding EP-11 | setTimeout + closures interview questions ( https://www.youtube.com/watch?v=eBTBG4nda2A&list=PLlasXeu85E9cQ32gLCvAvr9vNaUccPVNP&index=13 ). i have given the code below, kindly let me know if this could be considered as an another solution since it was giving me the correct output. function altSol(){ for (var i = 1;i<=5; i++){ setTimeout(function (i){ console.log(i); }(i),i*1000); } } altSol();

Read More