You need to sign in to do that
Don't have an account?
sheila srivatsav
keep two zeroes after decimal point javascript
I am not very good in javascript
I have a lightning component and in the controller.js file I have as shown below
var uos=claimlines.unitofservice;
when I debug this it returns a value of 30.0000
My client has told me to keep only two zeroes after the decimal point,
A working code would be greatly helpful.
thanks
sheila
I have a lightning component and in the controller.js file I have as shown below
var uos=claimlines.unitofservice;
when I debug this it returns a value of 30.0000
My client has told me to keep only two zeroes after the decimal point,
A working code would be greatly helpful.
thanks
sheila
Try the below one:
var uos=claimlines.unitofservice;
var x = uos;
x = Math.floor(x * 100) / 100;
alert(x.toFixed(2));
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Maharajan.C
All Answers
Try the below one:
var uos=claimlines.unitofservice;
var x = uos;
x = Math.floor(x * 100) / 100;
alert(x.toFixed(2));
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Maharajan.C
Please try this code to achieve two values after decimal.
var num = 30.0000;
var n = num.toFixed(2);
where The toFixed() method converts a number into a string, keeping a specified number of decimals.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha