-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
145 lines (119 loc) · 3.9 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var readlineSync = require('readline-sync');
var userName = readlineSync.question("Please enter your name....")
var welcomeMessage = "Hey " + userName + "! Welcome to Karan's NeoG MarkOne quiz on himself."
console.log(welcomeMessage);
var score = 0;
function play(question, answer){
var userAnswer = readlineSync.question(question);
console.log("---------------------")
if (userAnswer.toUpperCase() === answer.toUpperCase()){
console.log("You are right!")
score = score + 1;
} else {
console.log("Oh No! You are wrong!")
score = score -1;
}
console.log("Current Score = " + score);
console.log("---------------------")
}
var questionBankOne = [
{
question:"When was Karan Born? ",
answer: "16 January 2003"
},
{
question: "How many times has Karan changed the ROM on his phone? " ,
answer: "5"
},
{
question: "What is Karan's favourite IDE? ",
answer: "VS Code"
},
{
question: "Who is Karan's Favourite Astronaut? ",
answer: "Jim Lovell"
},
{
question: "On what spaceflight did an astronaut manually configure the directions after losing a resistance based gyrocope? This got Karan interested into Cosmos... " ,
answer: "Apollo 8"
},
{
question: "Physics vs Mathematics? ",
answer: "Mathematics"
}
]
for (var i=0; i<questionBankOne.length; i++){
var currentQuestion = questionBankOne[i];
play(currentQuestion.question, currentQuestion.answer);
}
var questionBankTwo = [
{
question:"Where does Karan Live? ",
answer: "Delhi"
},
{
question: "Where did Karan go to School? " ,
answer: "DAV Pushpanjali"
},
{
question: "On what device is Karan doing the LevelZero on? ",
answer: "Chromebook"
},
{
question: "What was Karan's First Car? ",
answer: "Vista"
},
{
question: "Which language did Karan learn after doing Sanskrit for 3 years after he switched schools? " ,
answer: "French"
},
{
question: "Who is Karan's FITTR Coach? ",
answer: "Himanshu Sachdeva"
}
]
if (score < 2){
console.log("You have not scored enough to continue onto the next level. Please reload the page to try again!")
} else {
var startLevelTwo = readlineSync.question("You have scored enough to proceed to Level Two, Press ENTER to keep Playing or E to exit.")
if (startLevelTwo.toUpperCase() === "e".toUpperCase()){
console.log("Oh No! We're Sorry to see you go, please go play again!")
} else {
console.log("----------------")
for (var j=0; j<6; j++){
var currentQuestionLtwo = questionBankTwo[j];
play(currentQuestionLtwo.question, currentQuestionLtwo.answer);
}
var finalScore = score;
console.log("Your Final Score is: " + score);
console.log("Let's see if you have beaten any High Scores...")
console.log("----------------")
var highScores = [
{ name: "Meenakshi",
score: "10"
},
{ name: "Gaurav",
score: "09"
}
]
for (var k=0; k<highScores.length; k++){
var scoreDisplay = highScores[k];
console.log("----------------")
console.log(scoreDisplay.name + ": " + scoreDisplay.score)
console.log("----------------")
}
if(finalScore > 10){
console.log("Congratulations! You won the first spot! Email us this screenshot at [email protected] and we'll put your name here.")
} else{
if (finalScore === 10){
console.log("Great Work! You tied for the first place. Send us this screenshot at [email protected] and we will put you here!")
} else{
if(finalScore === 9){
console.log("Great! You have Tied for the second place! Send us this screenshot at [email protected] and we will put you here")
} else{
console.log("Great Work!, you have come in third place. Send us this Screenshot at [email protected] and we will put you here.")
}
}
}
}
}