por qué Array.Map regresa indefinido
let test = [ {name:'test',lastname:'kumar',age:30},
{name:'test',lastname:'kumar',age:30},
{name:'test3',lastname:'kumar',age:47},
{name:'test',lastname:'kumar',age:28},
{name:'test4',lastname:'kumar',age:30},
{name:'test',lastname:'kumar',age:29}]
let result1 = test.map(element =>
{
if (element.age === 30)
{
return element.lastname;
}
}).filter(notUndefined => notUndefined !== undefined);
output : ['kumar','kumar','kumar']
// same output but simple code for above snippet
let result1 = test.filter(element =>
{
if (element.age === 30)
{
return element;
}
}).map(({lastname})=>lastname)
console.log(result1)
output : ['kumar','kumar','kumar']
Nasty Narwhal