<!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">
</head>
<body>
<h1>Text Quiz</h1>
<p>With an array of objects</p>
<p>Questions</p>
<p id = "question"></p>
<button id ="choice1" onClick="check('a')"></button>
<button id ="choice2" onClick="check('b')"></button>
</body>
<script src ="script.js"></script>
</html>
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');
@import url('https://fonts.googleapis.com/css?family=Merriweather:400,700');
body {
background-color: white;
font-family: "Open Sans", sans-serif;
padding: 5px 25px;
font-size: 18px;
margin: 0;
color: #444;
}
h1 {
font-family: "Merriweather", serif;
font-size: 32px;
}
button{
color:red;
width:200px;
font-size:20px;
background-color:yellow;
}
const questions = document.getElementById("question");
const choice1 = document.getElementById("choice1";)
const choice2 = document.getElementById("choice2");
var questions = [
{q:"how much is 1 + 1",a:"2",b:"1",ans:"a"},
{q:"3+4",a:"7",b:"34",ans:"a"},
{q:"3+10",a:"7",b:"13",ans:"b"},
{q:"What is the capital of SA",a:"Adelaide",b:"Brisbane",ans:"a"}
]
var qcount =0;
generateQuestion();
function check(but){
if(qcount<questions.length){
if(but == questions[qcount].ans){
console.log("correct");
}
else{
console.log("incorrect")
}
generateQuestion();
}
}
function generateQuestion(){
console.log(qcount + ", " + questions.length);
if(i<questions.length){
question.innerHTML=questions[qcount].q;
choice1.innerHTML="A. " + questions[i].a;
choice2.innerHTML="B. " + questions[i].b;
qcount +=1// parseInt(Math.random()*questions.length+1)
}
}