123456789101112131415161718192021222324252627 |
- let currency = prompt('Укажите валюту:');
- let exchangeRate = null;
- let exchangeRateSymbol = '';
- let ratios = {
- usd: 39.15,
- eur: 39.55
- }
- switch (currency) {
- case 'usd':
- exchangeRate = ratios.usd;
- exchangeRateSymbol = '$';
- break;
- case 'eur':
- exchangeRate = ratios.eur;
- exchangeRateSymbol = '€';
- break;
- default:
- alert('Неверно указанная валюта');
- }
- if(currency === 'usd' || currency === 'eur' ) {
- let quantity = +prompt('Укажите величину в гривне для обмена');
- alert(`${quantity} грн в ${currency} = ${(quantity / exchangeRate).toFixed(2)}${exchangeRateSymbol}`);
- }
|