0
I have this code, but I want to access a certain attribute of a object who is within an array, but is returning Undefined
obj1 = {
nome : 'name',
array : [],
funcao : function(element){this.array.push(element)},
getArray : function(){return this.array},
getNome : function(){this.array.forEach(element =>element.nome) }
}
obj2 = {
nome: 'name2'
}
obj1.funcao(obj2)
console.log(obj1.getArray())
console.log(obj1.getNome())
Why is the
return
?– Isac