-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
70 lines (60 loc) · 1.72 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
var readlineSync = require("readline-sync");
var score =0;
var highScores = [
{
name: "Alind",
score: 3,
}
]
var name =readlineSync.question("What's your name? \n")
console.log("HI "+name +"\nLet's play a game to know how well you know Alind")
//To use uppercase take care of brackets as in userAnswer.toUpperCase()
function play(question,answer){
var userAnswer=readlineSync.question(question);
if(userAnswer.toUpperCase()==answer.toUpperCase()){
console.log("your Answer is Right")
score++;
}else{
console.log("Sorry you're wrong");
}
console.log("Your Score is: "+ score);
console.log("question is: "+question + " Answer is: "+ answer)
console.log("--------")
}
var askingQuestions=[
{
question: "Where I live?\n",
answer: "chhatarpur"
},
{
question: "In which city i did my graduation?\n",
answer:"sagar"},
{question:"What is my Branch?\n",
answer:"mechanical"}
,{
question: "What is name of my school where i did my 12Th?\n"
,answer: "Maharishi vidya mandir"
},
{
question:"What is my cgpa?\n"
,answer: "7.83"
},
{
question: "What is name of my Hostel during graduation?\n"
,answer:"parimal"
}
]
for(var i=0; i<askingQuestions.length;i++){
var currentQuestion= askingQuestions[i]
play(currentQuestion.question , currentQuestion.answer);
}
// function showScores() {
console.log("YAY! You SCORED: ", score);
console.log("Check out the high scores, if you should be there ping me and I'll update it");
for(var j=0; j<highScores.length; j++){
var currentScore = highScores[j]
console.log(currentScore.name+ ": "+currentScore.score);
}
// highScores.map(score => console.log(score.name, " : ", score.score))
// console.log
// // }