-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasd.js
More file actions
42 lines (37 loc) · 1.1 KB
/
asd.js
File metadata and controls
42 lines (37 loc) · 1.1 KB
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
var randomItem;
var Question = function(question, answers, correctAnswer) {
this.question = question;
this.answers = answers;
this.correctAnswer = correctAnswer;
};
var question1 = new Question(
"What is Javascript?",
["styling lang", "serverscript lang", "database lang", "clientScript lang"],
3
);
var question2 = new Question(
"Which of the following is a JS framework?",
["CSS", "JQuery", "Panda", "HTML"],
1
);
var question3 = new Question(
"What is the function equivalent to in JS?",
["object", "integer", "array", "string"],
0
);
var questions = [question1, question2, question3];
function questionGenerator() {
randomItem = questions[Math.floor(Math.random() * questions.length)];
console.log(randomItem.question);
for (var i = 0; i < randomItem.answers.length; i++) {
console.log(i + ". " + randomItem.answers[i]);
}
}
questionGenerator();
var selectedAns = parseInt(prompt("Please enter the correct answer."));
//console.log(selectedAns);
if (selectedAns === randomItem.correctAnswer) {
console.log("That is correct!!!!");
} else {
console.log("That is incorrect :(");
}