我有一个包含一系列答案的变量,如下所示:
var answers = [
{"answerId":5,"text":"<p>xx</p>","correct":null,"response":true},
{"answerId":6,"text":"<p>yy</p>","correct":null,"response":false},
{"answerId":7,"text":"<p>zz</p>","correct":null,"response":false},
{"answerId":8,"text":"<p>aa</p>","correct":null,"response":false},
{"answerId":9,"text":"<p>bb</p>","correct":null,"response":false},
{"answerId":21,"text":"<p>cc</p>","correct":null,"response":false}];
和另一个包含响应数组的变量:
var reply = [
{"answerId":5,"correct":true},
{"answerId":6,"correct":false},
{"answerId":7,"correct":false},
{"answerId":8,"correct":false},
{"answerId":9,"correct":false},
{"answerId":21,"correct":false}];
如何使用每个 answerId 的正确响应更新 answers 变量?这样空值就被替换了吗?