-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (30 loc) · 1.06 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
#! /usr/bin/env node
// SHABANG (#SHA , !BANG)
import inquirer from "inquirer";
const answer = await inquirer.prompt([
{ message: "Enter first number", type: "number", name: "firstNumber" },
{ message: "Enter second number", type: "number", name: "secondNumber" },
{
message: "Select one of the operator to perform operation",
type: "list",
name: "operator",
choices: ["addition", "subtraction", "multiplication", "division"],
},
]);
console.log(answer);
//conditional statement
if (answer.operator === "addition") {
console.log("Your value is :", answer.firstNumber + answer.secondNumber);
}
else if (answer.operator === "subtraction") {
console.log("Your value is :", answer.firstNumber - answer.secondNumber);
}
else if (answer.operator === "multiplication") {
console.log("Your value is :", answer.firstNumber * answer.secondNumber);
}
else if (answer.operator === "division") {
console.log("Your value is :", answer.firstNumber / answer.secondNumber);
}
else {
console.log("Please select valid operator.");
}