javascript convert number to string with 2 decimal places 1

javascript convert number to string with 2 decimal places

var twoPlacedFloat = parseFloat(yourString).toFixed(2)

Here is what the above code is Doing:
1. parseFloat() is a built-in function that converts a string to a floating point number.
2. toFixed() is a built-in function that converts a number to a string, keeping only two decimals.

Similar Posts