-1
I want to consult the array of an element that is within a array through a for..of
and I want to unite the elements of array with the function join
, but I’m getting the error below and I don’t know why.
Error:
Cannot read property 'join' of undefined
Code:
var usuarios = [{
nome: "Lucas",
habilidaes: ["JavaScript", "NodeJS", "MongoDB", "HTML", "CSS"]
},
{
nome: "Rafael",
habilidades: ["JavaScript", "Java", "MySQL", "HTML", "CSS"]
}
];
function leitorHabilidades(usuarios) {
for (usuario of usuarios) {
console.log(
'O ' +
usuario.name +
' possui habilidade em: ' +
usuario.habilidades.join()
);
}
}
leitorHabilidades(usuarios);
You wrote
habilidaes
instead ofhabilidades
– Valdeir Psr