Im interested in why does parseFloat() return 0 in this case:
var priceFromJson = '0,33';
console.log(priceFromJson);
var tmpPrice = parseFloat(priceFromJson);
console.log('tmpPrice'+tmpPrice);
var price = parseFloat( ( tmpPrice ) * 1.2 ).toFixed(2);
console.log('price'+price);
result is:
0,33
tmpPrice0
price0.00
But if I do this:
var priceFromJson = '0,33';
console.log(priceFromJson);
var tmpPrice = parseFloat( priceFromJson.replace(',','.') );
console.log('tmpPrice'+tmpPrice);
var price = parseFloat( ( tmpPrice ) * 1.2 ).toFixed(2);
console.log('price'+price);
The result is:
0,33
tmpPrice0.33
price0.40
By http://www.w3schools.com/jsref/jsref_parsefloat.asp , but in my case the first char is zero.
Any idea?
EDITED (after comment):
So other decimals, for ex. "5,36" , "10,44" are works fine without the replace(). Any other idea, what should I do in these situations? What is the best method to eliminate this problem then practice it. Thanks