The reason being is that when you pass this number through to a function(a) a dose not read 217 it reads 143, needing the 0 in front, I just turned it in to a string but it is an weird error. I've had one other years ago with JavaScript and numbers?
Asked
Active
Viewed 14 times
-2
-
because it is octal when it is a leading zero. If you need the leading zero, you need to make it a string. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Numbers_and_dates#octal_numbers – epascarello Aug 31 '21 at 20:46
1 Answers
0
Numbers that start with 0 are considered to be octal numbers. 0817 is not a valid octal number, so it's handled as a decimal number instead.
0217 is a valid octal number, and it is equal to 143 in decimal representation.
pelmetennui
- 136
- 1
- 3