我有以下數據數組:如何使用字符串中的數據更新JavaScript對象?
var ans =
[
{"text":"x","response":false},
{"text":"y","response":false},
{"text":"z","response":true}
];
var correct = "010"; // I need to add this to the array ans
任何人都可以建議我如何使用使用的數據在正確的變量添加到陣列中,使:
var ans =
[
{"text":"x","response":false,"correct":false},
{"text":"y","response":false,"correct":true},
{"text":"z","response":true,"correct":false}
];
你到底想幹什麼? –