1

I have two numbers: 02.95 and 03.28

I would like to remove the extra 0 from front.

My Expected output: 2.95 and 3.28

How can I achieve this in Javascript?

Nital
  • 5,292
  • 20
  • 88
  • 174

1 Answers1

1

If they are individual strings themselves, the fastest and shortest way would be to convert them to numeric values with the Unary Plus (+) prefix:

+"02.95"  ->  2.95
+"03.28"  ->  3.28
James Donnelly
  • 122,518
  • 33
  • 200
  • 204