-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (50 loc) · 1.75 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
#! /usr/bin/env node
import inquirer from "inquirer";
import chalk from "chalk";
const Answer = await inquirer.prompt([
{
message: chalk.blue.bold.italic.bgYellowBright.bold("Kindly Enter Your First Number"),
type: "number",
name: "FirstNumber",
},
{
message: chalk.white.bold.italic.bgGreen.bold.underline("Kindly Enter Your Second Number"),
type: "number",
name: "SecondNumber",
},
{
message: chalk.black.yellow.underline.italic("*Select one of the operator to perform operation*"),
type: "list",
name: "operator",
choices: [
"Addition",
"Subtraction",
"Multiplication",
"Exponentiation",
"Division",
"Modulus",
],
},
]);
// "Conditional Statements":
if (Answer.operator == "Addition") {
console.log(chalk.whiteBright.bgRed("Your value is"), Answer.FirstNumber + Answer.SecondNumber);
}
else if (Answer.operator == "Subtraction") {
console.log(chalk.redBright.bgBlue("Your value is"), Answer.FirstNumber - Answer.SecondNumber);
}
else if (Answer.operator == "Multiplication") {
console.log(chalk.black.bgYellow("Your value is"), Answer.FirstNumber * Answer.SecondNumber);
}
else if (Answer.operator == "Exponentiation") {
console.log(chalk.black.bgGreen("Your value is"), Answer.FirstNumber ** Answer.SecondNumber);
}
else if (Answer.operator == "Division") {
console.log(chalk.gray.bgWhite("Your value is"), Answer.FirstNumber / Answer.SecondNumber);
}
else if (Answer.operator == "Modulus") {
console.log(chalk.blue.bgYellow("Your value is"), Answer.FirstNumber % Answer.SecondNumber);
}
else {
console.log(chalk.yellow.bgWhite.underline("Please select valid operator"));
}