-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (28 loc) · 959 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
#!/usr/bin/env node
import inquirer from "inquirer";
const answer = await inquirer.prompt([
{ message: "Enter 1st number:", type: "number", name: "firstNumber" },
{ message: "Enter 2nd number:", type: "number", name: "secondNumber" },
{
message: "Select one of the operators to perform operation:",
type: "list",
name: "operator",
choices: ["Addition", "Subtraction", "Multiplication", "Division"],
},
]);
// conditional statement
if (answer.operator === "Addition") {
console.log(answer.firstNumber + answer.secondNumber);
}
else if (answer.operator === "Subtraction") {
console.log(answer.firstNumber - answer.secondNumber);
}
else if (answer.operator === "Multiplication") {
console.log(answer.firstNumber * answer.secondNumber);
}
else if (answer.operator === "Division") {
console.log(answer.firstNumber / answer.secondNumber);
}
else {
console.log("Please select a valid operator");
}