var questions =[
new Question ("Who is the president of Czech Republic?", ["Donald Trump", "Andrej Kiska", "Milos Zeman", "Angela Merkel"], "Milos Zeman"),
new Question ("The capital of Czech Republic is:", ["Brno", "Ostrava", "Hradec Kralove", "Prague"], "Prague"),
new Question ("Which food is not common Czech food?", ["Cevapcici", "Svickova", "Trdelnik", "Tatarak"], "Cevapcici")];
var quiz = new Quiz(questions);
populate();
如何在此测验中随机化问题的顺序?以下是工作样本:
答案 0 :(得分:0)
使用随机数(demo)对其进行排序:
this.questions = [].concat(questions).sort(function() {
return Math.random() - Math.random();
});
[].concat(questions)
创建一个新数组,因此不会更改原始数组。