Basic JavaScript - Use the parseInt Function with a Radix

Is there more info on Radix? After reading the Radix wikipedia page, I dont understand how a Radix number can be greater than 10. This challenge says it can be any number between 2 and 36. And the wiki page says something different.

I also dont understand how this challenge outputs the value 19.

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

console.log(convertToInteger("10011"));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0

Challenge: Basic JavaScript - Use the parseInt Function with a Radix

Link to the challenge:

the number 10011 is binary
To understand how to convert between binary numbers and decimal please read here
http://www.steves-internet-guide.com/binary-numbers-explained/

Larger radixes is ancient maths. Before the decimal number system was invented for eg. the Babylonians used base 60 numbers. Read more here:
https://www.science.org.au/curious/video/dozenal-system

2 Likes

Thank you for this info, it really clarified things for me. Quick question. Practically speaking, in the programming world, how relevant is a non base 10 number system?

i would say the two most important number systems for a back-end developer especially (to some extent the front-end dev) is binary (base 2) and hexadecimal (base 16).

Binary because that’s the language of the computer.
Hex because it makes reading binary slightly easier and is used in places like CSS color codes and other places.

1 Like