set precision javscript code example Example: javascript convert string to 2 decimal var twoPlacedFloat = parseFloat(yourString).toFixed(2)