Home > front end >  how to convert 4 decimal string to 2 decimal string in typescript
how to convert 4 decimal string to 2 decimal string in typescript

Time:12-28

I'm getting value like this.

data[0].percentage='0.0000'

I want this value as =

'0.00'

how to convert

'0.0000' to '0.00'

i tried

parseFloat(data[0].percentage).toFixed(2) 

im getting NaN

CodePudding user response:

const percentage = '0.0000';
console.log(Number(percentage).toFixed(2));

  • Related