Adding JavaScript Decimal Places

2

I have 3 JavaScript variables:

valorUm = 2.8 //dois ponto oito
valorDois = 2.415 //dois mil quatrocentos e 15
valorLivre = 25 //vinte e cinco

What I need is:

valorUm + valorDois - valorLivre

This calculation returns -19.785 and should return me 2392.8

I'm retrieving input values:

valorUm = parseFloat(document.getElementById('ab').value.replace(",","."));
valorDois = parseFloat(document.getElementById('bc').value.replace(",","."));
valorLivre = parseFloat(document.getElementById('livre').value);
    
asked by anonymous 11.08.2015 / 03:39

1 answer

2

According to the description of the comment the necessary change should be this:

valorDois = parseFloat(document.getElementById('bc').value.replace(".",""));

It's still strange the other replace but if you think it's right, I will not question. Do not like converting a number that contains text but should work in this case. I find it strange that an API sends data this way to be consumed.

    
11.08.2015 / 04:06