© 2024 fjorge. All rights reserved.
What? parseInt('08') returns 0 with Javascript? WHY!

Turn a string into a number in Javascript is just
This works for just about everything.... except "08" and "09".
The leading zero in the string tells the Javascript engine that it is an octal number. Because 8 and 9 are not valid numbers in octal, parseInt returns 0. This is expected behavior because they are not valid octal integers and parseInt returns 0 because the first valid number encountered is a zero. – Resource
So, since they aren't octal you need to provide a base parameter. This is just good practice regardless, so make a habit of doing this and you'll never run into this problem.