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, } } switch (currency) { case 'usd': exchangeRate = sale ? ratios.usd.buy : ratios.usd.sale; exchangeRateSymbol = '$'; break; case 'eur': exchangeRate = sale ? ratios.eur.buy : ratios.eur.sale; exchangeRateSymbol = '€'; break; default: alert('Неверно указанная валюта'); } if(currency === 'usd' || currency === 'eur' ) { let quantity = +prompt('Укажите величину в гривне для обмена'); alert(`${quantity} грн по курсу ${sale ? 'продажи' : 'покупки'} в ${currency} = ${(quantity / exchangeRate).toFixed(2)}${exchangeRateSymbol}`); }