-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
90 lines (89 loc) · 1.97 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var readlineSync=require("readline-sync");
var score=0;
var userName=readlineSync.question("What is your name? ");
console.log("Welcome "+userName+" are you READY to play?");
console.log(" ");
console.log("👇 👇 Rules to play the QUIZ 👇 👇");
console.log(" ");
console.log("1] Correct answer will give you ONE mark.");
console.log("2] wrong answer will conduct ZERO mark.");
console.log("3] After end of quiz SCORE will be displayed.");
console.log(" ");
console.log("ALL THE BEST!!!");
console.log("________________________________________________________");
console.log(" ");
//play function
function play(question,answer)
{
var userAnswer=readlineSync.question(question);
if(userAnswer===answer)
{
console.log("right!");
score=score+1;
}
else
{
console.log("Wrong!");
}
console.log("current score: ",score);
console.log("--------------------------------------");
}
//Array of the objects
var questions=[
{
question:"Who is owner of Google? ",
answer:"Larry Page",
answer:"larry page",
},
{
question:"Who is owner of Facebook? ",
answer:"Mark Zukerberg",
answer:"mark zukerberg",
},
{
question:"Who is owner of Amazon? ",
answer:"Jeff Bezos",
answer:"jeff bezon",
},
{
question:"Who is founder of Microsoft? ",
answer:"bill gates",
answer:"paul allen",
},
{
question:"Who is founder of Youtube? ",
answer:"Jawed Karim",
answer:"jawed karim",
},
{
question:"Who is owner of Youtube? ",
answer:"Google",
answer:"google",
},
{
question:"Who is owner of whatsapp? ",
answer:"Facebook",
answer:"facebook",
},
{
question:"Who is founder of Apple? ",
answer:"Steve Jobs",
answer:"steve job",
},
{
question:"Who is owner of flipcard? ",
answer:"Sachin Bansal",
answer:"sachin bansal",
},
{
question:"Who is founder of Tesla? ",
answer:"Elon Musk",
answer:"elon musk",
}]
//loop
for(var i=0;i<questions.length;i++)
{
var currentQuestion=questions[i];
play(currentQuestion.question,currentQuestion.answer)
}
console.log("YEHHH!! You SCORED:",score);