-
Notifications
You must be signed in to change notification settings - Fork 0
/
00jiwon.js
42 lines (39 loc) · 1.17 KB
/
00jiwon.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
fetch('/policeQuiz', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action : 'police_oxQuiz' })
})
.then(response => response.json())
.then(data => {
const quizData = data.quiz;
let points = 0;
let value = -1;
const policeQuiz = document.getElementById('police-ox-quiz');
policeQuiz.innerHTML = `
<p>${JSON.stringify(quizData.q, null, 2)}</p>
<p>점수: ${points}</p>
`;
document.querySelector('#police-O').addEventListener('click', () => {
value = 1;
if (value === quizData.a) {
alert('맞았습니다!');
points += quizData.point;
}
else if (value !== quizData.a) {
alert('틀렸습니다!');
}
value = -1;
});
document.querySelector('#police-X').addEventListener('click', () => {
value = 0;
if (value === quizData.a) {
alert('맞았습니다!');
points += quizData.point;
}
else if (value !== quizData.a) {
alert('틀렸습니다!');
}
value = -1;
});
});