Nono.MA

Round to two decimals in TypeScript

SEPTEMBER 5, 2022

Here's how to round a decimal float number to two decimals in TypeScript.

parseFloat("123.456").toFixed(2);
// Returns 123.46

Of course, you could change toFixed(2) to any number to keep as many decimals as you wanted.

BlogCodeTypescript