parseInt

Aug 31, 2011 at 8:32pm

parseInt

Hi,

I don’t get it. I got the following script:
test=”05A”;
post (“test is “);
post (test,”n”);
post ( parseInt(test.slice(0,2)), “n”);
test=”08A”;
post (“test is “);
post (test,”n”);
post ( parseInt(test.slice(0,2)), “n”);

This gives me the following output:
js: test is 05A
js: 5
js: test is 08A
js: 0

Why doesn’t the second output give me 8?

Cheers

#58705
Aug 31, 2011 at 9:23pm

Never mind. This:
post ( parseInt(test,10), “n”);
works

#211059

You must be logged in to reply to this topic.