javascript convert int to float
JavascriptJavascript Problem Overview
I have a variable
var fval = 4;
now I want out put as 4.00
Javascript Solutions
Solution 1 - Javascript
JavaScript only has a Number type that stores floating point values.
There is no int.
Edit:
If you want to format the number as a string with two digits after the decimal point use:
(4).toFixed(2)
Solution 2 - Javascript
toFixed() method formats a number using fixed-point notation. Read MDN Web Docs for full reference.
var fval = 4;
console.log(fval.toFixed(2)); // prints 4.00