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,784
  • 26
  • 103
  • 195

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
  • 126,410
  • 34
  • 208
  • 218