-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
49 lines (36 loc) · 1.29 KB
/
Copy pathmain.ts
File metadata and controls
49 lines (36 loc) · 1.29 KB
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
#!/usr/bin/env node
import inquirer from "inquirer";
import chalk from "chalk";
const answers = await inquirer.prompt([
{
name: "firstNumber",
type: "number",
message: "Enter the first number"
},
{
name: "secondNumber",
type: "number",
message: "Enter the second number"
},
{
name: "operators",
type: "list",
message: "Enter the operators",
choices: ["Addition", "Subtraction", "Multiplication", "Division", "Modulus", "Exponentiation"]
}
]);
if(answers.operators === "Addition"){
console.log(answers.firstNumber + answers.secondNumber);
} else if(answers.operators === "Subtraction"){
console.log(answers.firstNumber - answers.secondNumber);
} else if(answers.operators === "Multiplication"){
console.log(answers.firstNumber * answers.secondNumber);
} else if(answers.operators === "Division"){
console.log(answers.firstNumber / answers.secondNumber);
} else if(answers.operators === "Modulus"){
console.log(answers.firstNumber % answers.secondNumber);
} else if(answers.operators === "Exponentiation"){
console.log(answers.firstNumber ** answers.secondNumber);
} else {
console.log(chalk.red.bold("Please select operators"));
}