let me get this straight the radix is used to tell parseInt which type of number system to use?
this is what i wrote in the function it still did not work, i’m not sure how the radix works tho
return ParseInt(str, 10);
function convertToInteger(str) {
}
convertToInteger("10011");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36.
Yes, the radix in the second argument of parseInt is the base, or type of number system that the string will use to parse out a number. If you use do parseInt(str, 10) on “10011”, it would become the number 10011.
I can’t be sure, but if you’re getting an error from the exact line of code you pasted in, it’s probably because you capitalized the P: parseInt is the name of the built-in function, not ParseInt.
The question is asking you to assume that the string “10011” represents a binary number, and convert it to a decimal base 10 number using parseInt. Since it represents a binary number, you would use 2 as the radix argument in parseInt.
It should return 19, since “10011” in binary represents 2^4 + 0^3 + 0^2 + 2^1 + 2^0 = 16 + 2 + 1 = 19.