let currency = prompt('Укажите валюту:'); let exchangeRateSymbol = ''; if(currency) { currency = currency.toLowerCase(); if(currency === 'usd') { exchangeRateSymbol = '$'; } else if(currency === 'eur') { exchangeRateSymbol = '€'; } else { alert('Неверно указанная валюта'); } } else { alert('Укажите валюту:'); } if(currency === 'usd' || currency === 'eur' ) { let quantity = +prompt('Укажите величину в гривне для обмена'); const fetchExchangeRate = (currency) => { fetch(`https://open.er-api.com/v6/latest/${currency}`) .then(res => res.json()) .then(data => { alert(`${quantity} грн в ${currency} = ${(quantity / data.rates.UAH).toFixed(2)}${exchangeRateSymbol}`); }); } fetchExchangeRate(currency); }