-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.js
87 lines (67 loc) · 2.38 KB
/
javascript.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
81
82
83
84
85
86
87
/* function generateQuiz(quizQuestions, quizContainer, resultContainer, submitButton) {
// The questions
var myQuestions = [
{
quizQuestion: "What is Malik's favourite color?",
answers: {
a: 'Black',
b: 'Blue',
c: "Blue-black"
},
correctAnswer: 'a'
},
{
quizQuestion: "What other thing does Malik identify as?",
answers: {
a: 'Broken mirror',
b: 'Sane madman',
c: 'A husband in the making!'
},
correctAnswer: 'b'
}
]
// Show Questions
function showQuestions(quizQuestions, quizContainer) {
// code will be here
var output = [];
var answers;
// for each question
for (var i = 0; i < quizQuestions.length; i++) {
// first reset the line of answers
answers = [];
// for each available answer to this question...
for (letter in quizQuestions[i].answers) {
// add an html radio button
answers.push(
'<label>'
+ '<input type="radio" name="question'+i+'" value="'+letter+'">'
+ letter + ': '
+ quizQuestions[i].answers[letter]
+ '</label>'
);
}
}
output.push(
'<div class="question">' + quizQuestions[i].quizQuestion + '</div>'
+ '<div class="answers">' + answers.join('') + '</div>'
);
}
// finally combine our output list into one string of html and put it on the page
quizContainer.innerHTML = output.join('');
}
showQuestions(quizQuestions, quizContainer);
// Show Result
function showResult(quizQuestions, quizContainer, resultContainer) {
// code will be here
}
showQuestions(quizQuestions, quizContainer);
// When users click the submit button
submitButton.onclick = function() {
showResult(quizQuestions, quizContainer, resultContainer);
}
}; */
window.addEventListener("load", () => {
const params = (new URL(document.location)).searchParams;
const myName = params.get("unknown");
document.getElementById("malik").innerHTML = myName;
})