Based on the following post: Rendering a dynamic survey
let questions = [{idquestion: 1, question:"age?"}, {idquestion: 2, question: "sex?"}];
let answers = [{idanswer: 1, answer:"17", idquestion: 1}, {idanswer: 2, question: "male", idquestion: 2}];
let questionanswer = {question: 'edad?', answer: '17'};
let questionsAndAnswers =
questions.map(question => {question:question, answer: answers.find((answer) => answer.idquestion === question.idquestion)})
I obtain the following errors:
question: unused label
answer: cannot find name answer
I want to obtain an object questionAndAnswers
with questions and answers related. How can I fix it?