+ 1
Why 0 is being excluded ?
Guys, i’m doing an javascript exercise and i got doubious. When i transformed the number following by 0 to string by adding with empty string, and then output the length. Why the length is not 5 ?? https://code.sololearn.com/W987q2v8qXt4/?ref=app
3 ответов
+ 2
There is no number start with 0, so it should be 4.
If you want 5, you have to declare it to string like
'02344'
Good Luck ~
+ 2
"Never write a number with a leading zero (like 07).
Some JavaScript versions interpret numbers as octal(base 8) if they are written with a leading zero." quote from W3Schools
https://www.w3schools.com/js/js_numbers.asp;
https://code.sololearn.com/Wk3c5vbCl6L2/#html