-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (36 loc) · 948 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
36
#!usr/bin/env node
import inquirer from "inquirer";
const currency = {
USD: 1,
EUR: 0.91,
GBP: 0.76,
INR: 74.57,
PKR: 288
};
let userAnswer = await inquirer.prompt([
{
name: "from",
message: "Enter from Currency",
type: "list",
choices: ["USD", "EUR", "GBP", " INR", "PKR"]
},
{
name: "to",
message: "Enter to Currency",
type: "list",
choices: ["USD", "EUR", "GBP", " INR", "PKR"]
},
{
name: "amount",
message: "Enter from Currency",
type: "number"
}
]);
let userfromCurrency = userAnswer.from;
let userToCurrency = userAnswer.to;
let fromAmount = currency[userfromCurrency]; //Exchange Rate
let toAmount = currency[userToCurrency]; // Exchange Rate
let amount = userAnswer.amount;
let baseAmount = amount / fromAmount; //USD base currencey
let convertedAmount = baseAmount * toAmount;
console.log(convertedAmount);