I make a currency converter and as a result it turns out that the condition operators are almost identical, it would be better to somehow optimize through the ternary operator
var exchan=document.getElementById("exchan");
exchan.addEventListener("click",function(e){
var numberOne=document.getElementById("numberOne").value;
var numberTwo=document.getElementById("numberTwo");
var sExchange;
var currencyOne=document.getElementById("currencyOne").value;
var currencyTwo=document.getElementById("currencyTwo").value;
if(currencyOne=="UAH" && currencyTwo=="USD"){
numberTwo.value=(numberOne/cursUSD).toFixed(2);
}
if(currencyOne=="UAH" && currencyTwo=="EUR"){
numberTwo.value=(numberOne/cursEUR).toFixed(2);
}
if(currencyOne=="UAH" && currencyTwo=="PLN"){
numberTwo.value=(numberOne/cursPLN).toFixed(2);
}
},false);
Aucun commentaire:
Enregistrer un commentaire