Use the parseInt Function with a Radix -- explanation needed

Tell us what’s happening:

I’m completely lost on this one.

What is a radix?
What is the base of a number?
What does the following line mean?

The radix variable says that “11” is in the binary system, or base 2. This example converts the string “11” to an integer 3.

Your code so far

function convertToInteger(str) {
  return parseInt(str, 2);


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:


So we normally use decimal, which is base 10, for most things in day to day life (with exceptions, eg time, which is base 60). So parseInt takes a string and makes an attempt to turn it into a number, but you can pass in a base (radix) which specifies the base, and it will give you an integer back.

How does this convert to 3?

Because 3 is 11 in binary

1 Like