I currently possess an array of Objects similar to this one.
let arr = [{name:"abc",age:26},{name:"xyz",age:23},{name:"pqr",age:10}]
let newVal = arr.map(function(el) {
if(el.age > 25){
var o = Object.assign({}, el);
o.gender = 'male';
return o;
}
})
console.log("New Val : " , newVal)
I am interested in appending {gender:'male'} to objects where the age exceeds 25.
However, it shows undefined for other objects.
I would greatly appreciate any assistance.
Thank you.