-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quiz-app.js
54 lines (46 loc) · 1.36 KB
/
Quiz-app.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
const prompt = require("prompt-sync")({sigint:true});
var name=prompt("enter your name: ")
// console.log(w)
var score = 15;
while (score > 0 && score < 30) {
var firstQuestion = prompt("What's the capital of Italy?");
switch (firstQuestion) {
case "Rome":
score = score + 5;
console.log("Your score is: " + score);
break;
default:
score = score - 5;
console.log("Your score is: " + score);
break;
}
var secondQuestion = prompt("What's the capital of France?");
switch (secondQuestion) {
case "Paris":
score = score + 5;
console.log("Your score is: " + score);
break;
default:
score = score - 5;
console.log("Your score is: " + score);
break;
}
var thirdQuestion = prompt("What's the capital of Spain?");
switch (thirdQuestion) {
case "Madrid":
score = score + 5;
console.log("Your score is: " + score);
break;
default:
score = score - 5;
console.log("Your score is: " + score);
break;
}
if (score == 0) {
console.log(name+": You lose!");
} else if (score == 30) {
console.log(name+": You win!");
} else {
console.log("Something went wrong!");
}
}