-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
64 lines (52 loc) · 1.5 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
const readlineSync = require('readline-sync');
const chalk = require('chalk');
let name = readlineSync.question(chalk.yellow('Hey there!, What\'s your good name? '));
while(name.length === 0) {
name = readlineSync.question(chalk.yellow('Hey there!, What\'s your good name? '));
}
console.log(chalk.yellow(`Welcome, ${name}! \n`));
console.log(chalk.yellow('Let\'s see how well do you know me! \n'));
let score = 0;
function askQuestion(ques, ans) {
let userAns = readlineSync.question(chalk.bold(ques));
while(userAns.length === 0) {
userAns = readlineSync.question(chalk.bold(ques));
}
if(userAns.toLowerCase() == ans.toLowerCase()) {
console.log(chalk.bold.greenBright('Exactly!!!:)'));
score++;
} else {
console.log(chalk.bold.red('Noo! You dont Know me:('));
console.log(chalk.bold.greenBright(`The answer is ${ans}.`));}
console.log(chalk.underline(`Score: ${score} \n`));
}
var quesList = [
{
q: 'What is my full name? ',
a: 'Harshavardhan Bisle',
},
{
q: 'Do you know my Girlfreind\'s name? ',
a: 'JavaScript',
},
{
q: 'which skill am I currently honing? ',
a: 'Programmming',
},
{
q: 'Where do I live? ',
a: 'Bangalore',
},
{
q: 'What is my qualification? ',
a: 'BE',
},
{
q: 'Which is my Department? ',
a: 'CSE',
},
];
for(var i=0; i<quesList.length; i++) {
askQuestion(quesList[i]["q"], quesList[i]["a"]);
}
console.log(chalk.italic.bold.bgBlue(`Your Final score is ${score} points!, feel free to connect with me to know more about me and keep learning `));