-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (40 loc) · 1.06 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
var readlineSync = require('readline-sync');
var score = 0;
var userName = readlineSync.question("What's your name? ");
console.log("hi "+userName + " welcome to the quiz!!! " );
var questions = [
{
question: "Doraemon is from which century ",
answer: "22nd"
},
{
question: "What does doraemon loves most in food ",
answer: "Doracakes"
},
{
question: "what Doraemon hates the most? ",
answer: "rats"
},{
question: "Doraemon's best friend ",
answer: "nobita"
},{
question: "what is the color of Doraemon ",
answer: "blue"
}
];
function gamePlay(question, answer){
var userAnswer = readlineSync.question(question);
if (userAnswer.toUpperCase() === answer.toUpperCase()){
console.log("You are right!!!");
score++;
}else{
console.log("worng");
}
console.log("Your current Score "+ score);
console.log("-----------------")
}
for (var i=0; i<questions.length; i++){
var currentQuestion = questions[i];
gamePlay(currentQuestion.question, currentQuestion.answer);
}
console.log(" your final Score " + score);