10_currency_calc.js 629 B

12345678910111213141516171819202122
  1. let currency = prompt('Укажите валюту:');
  2. let exchangeRate = null;
  3. let exchangeRateSymbol = '';
  4. switch (currency) {
  5. case 'usd':
  6. exchangeRate = 39.15;
  7. exchangeRateSymbol = '$';
  8. break;
  9. case 'eur':
  10. exchangeRate = 39.55;
  11. exchangeRateSymbol = '€';
  12. break;
  13. default:
  14. alert('Неверно указанная валюта');
  15. }
  16. if(currency === 'usd' || currency === 'eur' ) {
  17. let quantity = +prompt('Укажите величину в гривне для обмена');
  18. alert(`${quantity} грн в ${currency} = ${(quantity / exchangeRate).toFixed(2)}${exchangeRateSymbol}`);
  19. }