Guest User

Currency converter

a guest
Jan 14th, 2020
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function currencyConverter([arg1, arg2, arg3]) {
  2.     let monetaryValue = Number(arg1);
  3.     let inputCurrency = arg2;
  4.     let outputCurrency = arg3;
  5.     switch (inputCurrency) {
  6.         case "USD": monetaryValue *= 1.79549; break;
  7.         case "EUR": monetaryValue *= 1.95583; break;
  8.         case "GBP": monetaryValue *= 2.53405; break;
  9.     }
  10.     switch (outputCurrency) {
  11.         case "USD": monetaryValue /= 1.79549; break;
  12.         case "EUR": monetaryValue /= 1.95583; break;
  13.         case "GBP": monetaryValue /= 2.53405; break;
  14.     }
  15.     console.log(`${monetaryValue.toFixed(2)} ${outputCurrency}`);
  16. }
Add Comment
Please, Sign In to add comment