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 285 views
4 answers 475 views
2 answers 256 views
1 answer 320 views
2 answers 377 views
2 answers 371 views
...