-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript1.js
67 lines (44 loc) · 1.45 KB
/
script1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// let start = document.getElementById("start");
// start.addEventListener("click",()=>{
// document.querySelector(".welcome").innerHTML = "<b>Bye<b> and best of luck!!"
// })
// document.addEventListener("keydown",(e)=>{
// console.log("You have pressed "+ e.key);
// } )
let marksObtained = 0;
document.addEventListener('DOMContentLoaded', () => {
console.log(window.marks)
marksObtained = window.marks;
console.log(marksObtained)
})
let time = 10;
setInterval(() => {
document.querySelector(".timer span").innerHTML = time
if (time > 0) { time = time - 1; }
if (time == 0) {
setTimeout(() => {
console.log("quiz1 time done")
window.location.href = './quiz2.html';
}, 2000);
}
}, 1000);
let correctOptClicked = false;
let incorrectOptClicked = false;
document.getElementById('incorrect').addEventListener("click", function () {
incorrectOptClicked = true;
})
document.getElementById("correct").addEventListener("click", () => {
correctOptClicked = true;
});
document.getElementById('next').addEventListener('click', function () {
if (correctOptClicked) {
marksObtained += 5;
console.log("marks quiz "+marksObtained);
window.marks = marksObtained
}
else if (incorrectOptClicked) {
marksObtained -= 1
// console.log(marksObtained);
window.marks = marksObtained
}
});