Tell us what’s happening:
Just not understanding why this is converted to an integer with a value of 3. I understand that “11” has a radix of 2, because there are 2 digits in the string; but when converted, why does this turn to 3?
Any help is appreciated; thanks!
Your code so far
function convertToInteger(str) {
return parseInt(str, 2);
}
convertToInteger("10011");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15
Challenge: Basic JavaScript - Use the parseInt Function with a Radix
Link to the challenge: