我喜欢有数组或对象,例如:
[0]
text:"first"
id: 1
[1]
text:"second"
id: 2
[2]
text:"third"
id: 3
让自己:
1: first
2: 1
3: second
4: 2
5: third
6: 3
这是我目前对数组实现的javascript:
var numberOfQuestions = questionaireResult.numberOfQuestions;
var i;
var j;
var result = [];
for (i = 0; i < numberOfQuestions; i++) {
debugger;
var question = questionaireResult.questions[i].text;
var questionID = questionaireResult.questions[i].id;
for (j = 0; j < questionaireResult.questions[i].answers.length; j++) {
var text = questionaireResult.questions[i].answers[j].text;
var id = questionaireResult.questions[i].answers[j].id;
result.push(text, id);
}
}
请帮助获取结构化数组或对象