I have a problem with fn.call () within a method in an object. I have an arrangement that internally has objects, the values of these objects are type and gender.
const gustos = [
{tipo:'libros', genero: 'futuristas'},
{tipo:'musica', genero: 'rap'}
]
class User{
constructor(name){
this.name = name
}
listarGustos(arr){
length = arr.length
console.log(arr)
for(let i = 0; i <length; i++){
return function (i){
console.log('${this.tipo} : ${this.genero}')
console.log(i)
}.call(arr[i])
}
}
}
const victor = new User("victor")
victor.listarGustos(gustos)
to make the sentence of victor.listarGustos (tastes) is only returning me 'books: futurists' that is only the first value of the array is returning me likes. Any correction that I have to make to my code? thanks in advance