I’m trying to map the text of a database of given asnwers in a List for my quiz App.
The problem is that i have to acces the title in an array of array of objects like this:
log of the database in console
I tried to map as usual using
console.log(answerQuestionId.map(element => `${element.testo}`));
but it returns an array of udefined. Can anyone help me with that? I want to get an array of arrays with only the text of the answers
2
Answers
The element you are accessing the attribute "testo" is an array itself.
try with this:
hopefully it will work
I hope you are expecting an array of arrays with only
testo
data.Check the code below.
answerQuestionId.map(item => item.map(innerItem => innerItem.testo))