-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
70 lines (68 loc) · 1.57 KB
/
index.ts
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import inquirer from "inquirer";
let Conversions = {
"PKR":{
"US Dollar":0.0036,
"Pound Sterling":0.0028,
"Euro":0.0033,
"Chinese Yuan":0.026,
"PKR": 1
},
"Pound Sterling":{
"US Dollar":1.29,
"Euro":1.19,
"PKR":358.32,
"Chinese Yuan":9.32,
"Pound Sterling":1
},
"Euro":{
"US Dollar":1.09,
"Pound Sterling":1.19,
"PKR":302.18,
"Chinese Yuan":7.87,
"Euro":1
},
"US Dollar":{
"Pound Sterling":0.78,
"Euro":0.92,
"PKR":278.50,
"Chinese Yuan":7.25,
"US Dollar":1
},
"Chinese Yuan":{
"US Dollar":0.14,
"Pound Sterling":0.11,
"Euro":0.13,
"PKR":38.39,
"Chinese Yuan": 1
}
}
const answers:{
from:"PKR"|"US Dollar"|"Pound Sterling"|"Euro"|"Chinese Yuan",
to:"PKR"|"US Dollar"|"Pound Sterling"|"Euro"|"Chinese Yuan",
amount:number
}=await inquirer.prompt([
{
type:"list",
name:"from",
choices:["PKR","US Dollar","Pound Sterling","Euro","Chinese Yuan"],
message:"Select your Currency:"
},
{
type:"list",
name:"to",
choices:["PKR","US Dollar","Pound Sterling","Euro","Chinese Yuan"],
message:"Select your conversion Currency",
},
{
type:"number",
name:"amount",
message:"Enter your conversion amount: "
}
]);
const{from,to,amount}=answers;
if(from && to && amount){
let result =Conversions[from][to]*amount
console.log(`Your conversion from ${from} to ${to} is ${result}`)
}else {
console.log("Invalid inputs!")
};