-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (35 loc) · 1008 Bytes
/
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
import inquirer from "inquirer";
const answer = await inquirer.prompt([
{
type: "number",
name: "num1",
message: "Enter First Number?",
},
{
message: "Enter Second Number",
type: "number",
name: "num2",
},
{
message: "Select what operation you need to perform",
type: "list",
name: "operator",
choices: ["Addition", "Subtraction", "Multiplication", "Division"]
},
]);
if (answer.operator === "Addition") {
let result = answer.num1 + answer.num2;
console.log(`the result is ${result}`);
}
else if (answer.operator === "Subtraction") {
let result = answer.num1 - answer.num2;
console.log(`the result is ${result}`);
}
else if (answer.operator === "Multiplication") {
let result = answer.num1 * answer.num2;
console.log(`the result is ${result}`);
}
else if (answer.operator === "Division") {
let result = answer.num1 / answer.num2;
console.log(`the result is ${result}`);
}