Not understanding parseInt

" The parseInt() function parses a string and returns an integer. It takes a second argument for the radix, which specifies the base of the number in the string. The radix can be an integer between 2 and 36.

The function call looks like:

parseInt(string, radix);

And here’s an example:

var a = parseInt("11", 2);

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

Use parseInt() in the convertToInteger function so it converts a binary number to an integer and returns it."
Could someone explain all this to me
All this is a BIT TOO complicated for a beginner like me

this expect a bit of maths background knowing number systems with different bases

for example 11 in base 2 converted in base 10 becomes 3

you could do that using the parseInt function, which returns a number in base 10 (our usual number system)

the first argument is the number to convert, and the second argument is the base: so if the input is "11", 2 it will return 3

1 Like

If you are working with numbers in the base ten system (the number system that humans use) then you don’t have to worry about the radix. If you are using parseInt to convert from another number system (binary, octal, hexadecimal, etc) then you need to worry about it.

How many bases(I didn’t get a better word for it), like base 10, hexadecimal, octal, binary. And what are all of those.

What are they all called, “types of bases” or “bases”?

1 Like