budget.js
// Convert sum to the desired currency

Convert sum to the desired currency
Convert sum to the desired currency
function convertToCurrency() {
           let indexChange1 = currency_names.indexOf(document.getElementById("currencyToChange").value);
           let indexChange2 = currency_names.indexOf(document.getElementById("currencyToChangeTo").value);    
           let sum = document.getElementById("currencySum").value;
           if( sum.length == 0 ) {
               let result = document.getElementById("convertCurrencyResult");
               result.value = ''
           } else {
               if(isNaN(sum)) {
                   let result = document.getElementById("convertCurrencyResult");
                   result.value = 'NaN'
               } else {
                   let result = document.getElementById("convertCurrencyResult");
                   sum = parseFloat(sum / currency_values[indexChange1]); 
                   sum = parseFloat(sum * currency_values[indexChange2]);
                   sum = Math.round((sum + Number.EPSILON) * 100) / 100; 
                   result.value = sum;
               }
           }
       }
function convertToCurrency ( ) { let indexChange1 = currency_names . indexOf ( document . getElementById ( "currencyToChange" ) . value ) ; let indexChange2 = currency_names . indexOf ( document . getElementById ( "currencyToChangeTo" ) . value ) ; let sum = document . getElementById ( "currencySum" ) . value ; if ( sum . length == 0 ) { let result = document . getElementById ( "convertCurrencyResult" ) ; result . value = '' } else { if ( isNaN ( sum ) ) { let result = document . getElementById ( "convertCurrencyResult" ) ; result . value = 'NaN' } else { let result = document . getElementById ( "convertCurrencyResult" ) ; sum = parseFloat ( sum / currency_values [ indexChange1 ] ) ; sum = parseFloat ( sum * currency_values [ indexChange2 ] ) ; sum = Math . round ( ( sum + Number . EPSILON ) * 100 ) / 100 ; result . value = sum ; } } }
Convert sum to the desired currency
Convert sum to the desired currency
// in euro
