我已经实现了一个游戏应用程序,其中有四个选项,其中有一个答案。选项是随机排列的。如何检查所选选项是否为正确答案?
问问题
184 次
2 回答
1
保留将问题索引NSArray
或NSDictionary
问题与答案相关联的 or ?
于 2009-12-09T08:00:49.877 回答
0
这份灵魂之作,
const quiz = [
{
question: 'this is a question',
answer: 'the answer',
choices: []
}
];
quiz.forEach(item => {
console.log(item.question);
// im hardcoding the selected answer as an example be sure to dynamically populate this with the users input
let selectedAnswer = 'the answer';
if (selectedAnswer === item.answer) {
console.log('correct answer');
} else {
console.log('incorrect answer');
}
});
于 2021-07-25T06:07:58.507 回答