I created a simple apps script as follows:
function testeBug() {
Logger.log(parseInt("07"));
Logger.log(parseInt("08"));
}
And here's the logger output:
[13-06-19 23:09:13:130 BRT] 7.0 [13-06-19 23:09:13:130 BRT] NaN
Why this is happening? I'm using Google Apps Script
You need to pass in the radix parameter to parseInt
parseInt("08", 10);
Failure to do so causes some browsers to treat strings with a leading zero as base-8, which is what you're seeing, since 07 in base-8 is 7, while 08 is invalid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With