-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (64 loc) · 1.5 KB
/
index.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
var readlineSync = require('readline-sync');
var score = 0;
var userName = readlineSync.question("What is your name? ");
var welcomeMsg = "Welcome to the quiz " + userName + "! Let's see how will you answer";
var highScore = [
{
name: "aditya",
score: 5,
},
{
name: "chandan",
score: 3,
}
]
function quiz1(questions, answer) {
var userAns = readlineSync.question(questions);
if (answer.toUpperCase() === userAns.toUpperCase()) {
console.log("correct answer");
score++;
console.log(score);
}
else {
console.log("wrong answer");
score--;
console.log(score);
}
}
var questionList = [
{
question: "what is tony stark best suit? ",
answer: "marklxxxv"
},
{
question: "which company car is mostly used by tony stark ",
answer: "audi"
},
{
question: "what is tony stark if not Irnoman ",
answer: "scientist"
},
{
question: "which year iron man 1 is released? ",
answer: "2008"
},
{
question: "What is the name of tony stark daughter? ",
answer: "morgan stark"
},
{
question: "What is the name of Ironman 1st suit? ",
answer: "mark one"
},
{
question: " What is the name of the suit he used to defeat hulk",
answer: "hulk buster suit "
}
];
for (var i = 0; i < questionList.length; i++) {
quiz1(questionList[i].question, questionList[i].answer)
}
console.log("total score is ", score);
for (var j = 0; j < highScore.length; j++) {
console.log(highScore[j].name + ":" + highScore[j].score);
}