How to convert float to string with 2 decimal places in TypeScript

1 Answer

0 votes
const f: number = 787324.9871;

const s: string = f.toFixed(2);

console.log(s);



/*
run:

"787324.99" 

*/

 



answered Feb 12, 2023 by avibootz

Related questions

2 answers 112 views
2 answers 127 views
1 answer 151 views
2 answers 173 views
2 answers 155 views
...