我想做一个每次随机化问题的测验。我得到的东西随机化答案而不是问题。这是我到目前为止所得到的。
Principal
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial- scale=1">
<title>Made with Thimble</title>
<link rel="stylesheet" href="style.css">
答案 0 :(得分:1)
您只能提示一次,然后存储在变量中以选择所有测验元素..
quiz.forEach(q => q.choices.scramble());
var x = prompt("Select question number #:");
var ans = ""
function myFunction(item, index) {
ans += "\n[" + (index+1) + "]: " + item ;
}
quiz[x].choices.forEach(myFunction);
var y = prompt(quiz[x].question+"\nYour anwser is:"+ans);
if (y == quiz[x].correct){
alert("Correct!");
}else{
alert("Wrong! \nThe right answer is "+quiz[x].correct);
}