Hello,
I am super confused about how the parseInt() function works. I get the easy part in that if you pass it a string it will return a number. That portion is very straightforward. For example:
parseInt(“007”) // would return 7
Where I am super lost on this is when you start incorporating the radix into the function. In the example they had the following:
var a = parseInt("11", 2);
Why would this above example return 3?
I was also trying to reference some other resources for this and got even more lost. The following are examples from Mozilla. Why would all the following examples return 15?
parseInt(‘0xF’, 16)
parseInt(‘F’, 16)
parseInt(‘17’, 8)
parseInt(021, 8)
parseInt(‘015’, 10) // but parseInt(015, 8)
will return 13
parseInt(15.99, 10)
parseInt(‘15,123’, 10)
parseInt(‘FXX123’, 16)
parseInt(‘1111’, 2)
parseInt(‘15 * 3’, 10)
parseInt(‘15e2’, 10)
parseInt(‘15px’, 10)
parseInt(‘12’, 13)