Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How divide two numbers in java script

I am facing the issue in division of numbers in java script.

Example:

 var x= 2500, var y = 100

 alert(x/y)

is showing 25.

I need the answer in 25.00 format. What can I do?

When I divide 2536/100, it gives as expected.

like image 942
Amila Avatar asked Mar 02 '26 09:03

Amila


1 Answers

You can try number.toFixed(x)

alert( (x/y).toFixed(2) )
like image 183
Sandeep Pathak Avatar answered Mar 04 '26 22:03

Sandeep Pathak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!