-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsfile.js
80 lines (61 loc) · 3.2 KB
/
jsfile.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// STYLING FUNCTIONS, EVENTS AND CODE
//nh NH
var coverpage= document.querySelector('#coverpage');
let slidebutton= document.querySelector('.slideup');
slidebutton.addEventListener('click', function () {
coverpage.classList.toggle('slidemove');
gamecommences(questionat);
} )
const questions=[
{
question:'In what year did Nigeria attain independece ?',
options: ['1st November 1999', '25th May 1909','4th July 1878','30th January 1990', ' 24th March 1900',],
answer: '25th May 1909'
} ,
{
question:'In what Season of Game of thrones did the Arya stark ask the question "what\'s west of westeros " ?',
options: ['Season six (6)', 'Season five (5)','Season seven (7)','Season fourteen (14)', 'Season ten (10)'],
answer: 'Season six (6)'
},
{
question:'What is Arya Stark\'s Real Name?',
options: ['Maisie Williams', 'Kit Harrington','Thomas Dubwa','Lena Headey', 'Jeniffer Lawrence'],
answer: 'Season six (6)'
},
{
question:'The term "PANSEXUAL" refers to individuals of what kind of sexuality',
options: ['The Opposite sex', 'The same sex','Both sexes','All sexes', 'All of the above mentioned'],
answer: 'Season six (6)'
}
]
questionat=0;
function gamecommences(currentq) {
let screendisp= document.querySelector('#screen');
screendisp.textContent=questions[questionat].question;
let optiondisp= document.querySelectorAll('.option');
for(i=0; i<optiondisp.length;i++) {
optiondisp[i].textContent=questions[questionat].options[i];
optiondisp[i].addEventListener("click", function () {
if (this.textContent== questions[questionat].answer) {
var winorlose= document.querySelector('.winorlose');
winorlose.innerHTML='Correct! YOU HAVE EARNED 5 POINTS';
let dialogbox= document.querySelector('#alertbox');9
dialogbox.classList.add('alertdisplay');
}
else{
var winorlose= document.querySelector('.winorlose');
let dialogbox= document.querySelector('#alertbox');
dialogbox.classList.add('alertdisplay');
winorlose.innerHTML="OOPS! YOU DIDN'T GET IT RIGHT. THE CORRECT ANSWER IS " + "" + questions[questionat].answer;
}
}
)
let decision= document.querySelectorAll('.decision');
for(i=0; i<decision.length; i++) {
decision[i].addEventListener("click", function() {
if (decision[i].textContent=="") {
}
})
}
}
}