1234567891011121314151617181920212223242526272829303132 |
- let currency = prompt('Укажите валюту:').toLowerCase();
- let sale = confirm('Укажите тип операции - продажа или покупка?');
- let exchangeRate = null;
- let exchangeRateSymbol = '';
- let ratios = {
- usd: {
- buy: 39.15,
- sale: 38.45,
- },
- eur: {
- buy: 39.55,
- sale: 38.55,
- }
- }
- if(currency === 'usd') {
- exchangeRate = sale ? ratios.usd.buy : ratios.usd.sale;
- exchangeRateSymbol = '$';
- } else if(currency === 'eur') {
- exchangeRate = sale ? ratios.eur.buy : ratios.eur.sale;
- exchangeRateSymbol = '€';
- } else {
- alert('Неверно указанная валюта');
- }
- if(currency === 'usd' || currency === 'eur' ) {
-
- let quantity = +prompt('Укажите величину в гривне для обмена');
- alert(`${quantity} грн по курсу ${sale ? 'продажи' : 'покупки'} в ${currency} = ${(quantity / exchangeRate).toFixed(2)}${exchangeRateSymbol}`);
- }
|