The numStr is the string of the number you want converted, and the radix is the base you want. In the function you are supposed to build, you are passed the number (string) and you are to assume that the radix is 2. You just need to return the result of that. It should just be one line. I would right it out, but that would give it away.
Don’t calculate the number, let parseInt do it for you.
If that isn’t clear, please ask for more clarification.
Why was “2” chosen for radix (and passed) but another number like “36” doesn’t pass at all? Also, when I tried “5,” it passed all but 2 tests. I was playing around with the numbers between 2 and 36 to see if it would pass no matter which number was in this particular challenge. I guess I just don’t understand the logic of the entire challenge.
@kevinSmith That makes sense now! I suppose my brain just overlooked it. The introduction in the wiki link helped. For whatever reason, I wasn’t thinking about base at all much less base 2. I think I was most focused on “The radix can be an integer between 2 and 36” in the challenge.
parseInt() convert a number to your normal way of counting (base 10), you need to tell it in which base the string you use is in, and as that is in binary the base (the radix) is 2. You are using the parseInt() function to convert a string str that is written in binary radix=2 to the decimal system
If the string was in a ternary counting system you would have written radix=3.
FCC isn’t meant to be comprehensive. Not every little thing gets explained. Things like radices are more of a math concept. Many of remember how they work from from school. It’s cool if you don’t (we all run into some things that we don’t remember.) FCC expects you to go out and figure out the things you don’t understand. Reread the lesson and if you can’t find it, google it. And if that doesn’t help, check here.
If FCC explained every little thing that everyone could possibly not know, it would balloon to 100x its size. And a lot of people would get bored. Radix/base/binary is basic math. It’s cool that some people don’t remember, but FCC is not in the business of teaching math, basic or otherwise. Probably most of the people who come here are pretty tech/science/math savvy so it’s reasonable to assume that most people won’t need that (again, basic math, not programming) explained. Again, I’m not putting down people that don’t remember that from school - there are plenty of things I don’t remember. I don’t think there is a need for FCC to duplicate information that is already readily available elsewhere, especially when it is math and not programming. (Decades ago, understanding binary was fundamental to programming, but in a high level language like JS, you hardly ever need it. I can’t remember needing it once in JS.)
I would also point out that knowing how to go out and find things on your own is fundamental to programming. It is impossible to teach you everything you know about programming. And by the time you get a job, 10% of it will be obsolete anyway. For example, when I started FCC, ES6 still wasn’t expected, and React has gone through some radical changes.
As a professional developer, I go to the docs or google or stack overflow at least once a day. On some days, if I’m working with a new library, it can be several times an hour. My boss doesn’t provide tutorials. Developers are expected to just know how to tell what they need to figure it out, know how to figure it out, and go and do it. I think it’s a good thing that FCC doesn’t hold your hand and spoon feed you everything.
But FCC is a volunteer organization. If you really, really think FCC needs to teach this, then you can go to the git repo and create and issue. If you really want to be a hero, you can edit that problem or create a new section on basic math and do a PR. But it is a volunteer organization that works hard and I think has done a pretty good job of delivering fairly good product for free.