0

Possible Duplicate:
Workarounds for JavaScript parseInt octal bug

I have the following numbers:

01 02 03 04 05 06 07 08 09 10 11 12

These are a string I want to convert them to an int. So 02 becomes 2. I have parseInt('02') but this returns int 0

Community
  • 1
  • 1
Will
  • 1,393
  • 5
  • 14
  • 21

2 Answers2

1

Include the radix: parseInt('02', 10)

Emmett
  • 14,035
  • 12
  • 56
  • 81
0

You need to tell javascript the type of number you're trying to convert.

parseInt('02', 10); // number is base 10

See this question for more details.

Community
  • 1
  • 1
scurker
  • 4,733
  • 1
  • 26
  • 25