USD
EUR
GBP
function convertCurrency() { const exchangeRates = { USD: 1, EUR: 0.86, GBP: 0.76 }; const inputValue = document.getElementById(“inputValue”).value; const inputCurrency = document.getElementById(“inputCurrency”).value; const outputCurrency = document.getElementById(“outputCurrency”).value; const output = inputValue * exchangeRates[outputCurrency] / exchangeRates[inputCurrency]; document.getElementById(“output”).innerHTML = `${inputValue} ${inputCurrency} = ${output.toFixed(2)} ${outputCurrency}`; }
to
USD EUR GBPfunction convertCurrency() { const exchangeRates = { USD: 1, EUR: 0.86, GBP: 0.76 }; const inputValue = document.getElementById(“inputValue”).value; const inputCurrency = document.getElementById(“inputCurrency”).value; const outputCurrency = document.getElementById(“outputCurrency”).value; const output = inputValue * exchangeRates[outputCurrency] / exchangeRates[inputCurrency]; document.getElementById(“output”).innerHTML = `${inputValue} ${inputCurrency} = ${output.toFixed(2)} ${outputCurrency}`; }
Comments are closed.