Back
Below is my code:
price_result = parseFloat(test_var.split('$')[1].slice(0,-1));
I want to add two decimal places when price_result = integer. For example, if it’s 10, the output should be 10.00. Can anyone tell me how to implement it?
Try toFixed(). See the code implementation below:
var decimalTwo = parseFloat(yourString).toFixed(2)
If you want to learn more about Java, then go through this Java tutorial by Intellipaat for more insights.
31k questions
32.8k answers
501 comments
693 users