-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
65 lines (59 loc) · 1.37 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
var readLineSync = require("readline-sync");
//const chalk = require("chalk");
//define score var
var score = 0
var userName = readLineSync.question("What is your lovely name? " + "\n")
console.log("Hey " + userName + "! Welcome to HOW MUCH DO YOU KNOW KAVYA? \n")
var players = [
{
playerName: "Kavya",
Score: 5
}
]
//prepare list of questions
var questions = [
{
question: "What is my insta art account name? ",
answer: "kavryo"
},
{
question: "What is my favourite ice cream flavour? ",
answer: "chocolate"
},
{
question: "What is my hobby? ",
answer: "art"
},
{
question: "What is my go to game? ",
answer: "apex legends"
},
{
question: "What genre of game do I like? ",
answer: "fps"
}
]
function play(question,answer)
{
var userAnswer = readLineSync.question(questions[i].question + "\n")
if(userAnswer.toUpperCase() === questions[i].answer.toUpperCase())
{
console.log("\ncorrect! \n")
score++
}
else
{
console.log("\nincorrect! \n")
}
//show score at end
}
for(i = 0; i < questions.length; i++)
{
play(questions[i].question,questions[i].answer)
}
console.log("Your score is: " + score + "\n")
console.log("******** Highest Score ******** \n")
for( i = 0; i < players.length; i++)
{
console.log("Player : " + players[i].playerName + "\n" + "Score : " + players[i].Score + "\n");
}