-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (37 loc) · 1.07 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
var readLineSync = require('readline-sync');
var userName = readLineSync.question("What is Your Name?");
console.log("welcome " + userName + " to Do YOU KNOW VIDHI?");
var highScores = [
{
name: "Dhruvik",
score: 3,
},
{
name: "Dhruvi",
score: 3,
},
]
var score = 0;
function play(question, answer) {
var userAnswer = readLineSync.question(question);
if (userAnswer.toUpperCase() === answer.toUpperCase()) {
console.log("Right!");
score = score + 1;
} else {
console.log("Wrong!");
score = score - 1;
}
console.log("your current score: ", score);
console.log("-----------------------")
}
play("where do i live?", "Gujarat");
play("How old am i?", "19");
play("where do i study? ", "Gec");
play("what is my favorite song? ", "ilahi");
play("what is favourite color?", "Black");
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");
highScores.map(score => console.log(score.name, " : ", score.score))
}
showScores();