After reading the contents of this post about rendering dynamic surveys
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)})
The errors I encountered are:
question: unused label
answer: cannot find name answer
I am trying to create an object named questionAndAnswers
that combines questions and their respective answers. How can I resolve this issue?