Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function currencyConverter([arg1, arg2, arg3]) {
- let quantity = Number(arg1);
- let sourceCurrency = arg2.toLowerCase();
- let convertedCurrency = arg3.toLowerCase();
- if (sourceCurrency == 'bgn') {
- quantity = quantity / 1;
- } else if (sourceCurrency == 'usd') {
- quantity = quantity / 1.79549;
- } else if (sourceCurrency == 'gbp') {
- quantity = quantity / 2.53405;
- } else if (sourceCurrency == 'eur') {
- quantity = quantity / 1.95583;
- }
- if (convertedCurrency == 'bgn') {
- quantity = quantity * 1;
- } else if (convertedCurrency == 'usd') {
- quantity = quantity * 1.79549;
- } else if (convertedCurrency == 'gbp') {
- quantity = quantity * 2.53405;
- } else if (convertedCurrency == 'eur') {
- quantity = quantity * 1.95583;
- }
- console.log(quantity.toFixed(2) + ' ' + convertedCurrency)
- }
- currencyConverter(['20', 'gbp', 'bgn'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement