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 290 views
4 answers 479 views
2 answers 260 views
1 answer 322 views
2 answers 382 views
2 answers 379 views
...