'add trailing zeroes if a number is an integer in TypeScript
i have this script that uses a Regex to format a number and show only 2 digits after the float point:
let value =9.0111;
var n = value.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0];
console.log(n)
//Output: 9.01
how to show two zero digits after the float point if the let value is an integer?
like 9.00 ?
is there a way to do it using only the RegEx ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
