12345678910111213141516171819202122232425262728 |
- let currency = prompt('Укажите валюту:').toLowerCase();
- 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}`);
- }
|