-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.js
58 lines (42 loc) · 1015 Bytes
/
testing.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
var readlineSync = require('readline-sync')
var userName = readlineSync.question("what's ur name? ");
console.log("Welcome " + userName + " Do you knw Aman? ");
var score= 0;
//play function
function play(question,answer){
var userAnswer = readlineSync.question(question);
if(userAnswer.toUpperCase() === answer.toUpperCase()){
console.log("correct")
score = score+1;
}
else{
console.log("wrong")
}
console.log("current score ",score);
console.log("---------")
}
//array of objects
var questions = [{
question: "Where I live? ",
answer: "mumbai"
},{
question: "my favorite place to be at? ",
answer:"navsari "
}];
//loop
for(var i=0;i<questions.length;i++){
var currentQuestion = questions[i];
play(currentQuestion.question,currentQuestion.answer)
}
console.log("Yay!!! you scored", score);
//data score
var highscore =[ {
name: "Aman",
score:10
},
{
name: "Amanda",
score:9
}]
//need a forloop to run this...
//then check with if which one is bigger