JSFiddle - React, Tailwind, and code Playground
by Arif Hasan
JavaScript
Try following
let arr1 = [
{
"name": "Study",
"questions": [
{
"question": "Would you Love to learn about Java?",
"answer": "Yes"
}
]
},
{
"name": "Song",
"questions": [
{
"question": "Would you Love to learn about song?",
"answer": "Yes"
},
{
"question": "Would you Love to learn about rock?",
"answer": "No"
}
]
}
]
arr1.map((element, index) => {
{
questions: element.questions.map((e, i) => {
console.log(e); console.log(i); return {
...e,
name: element.name
};
})
}
})