Use the parseInt Function with a Radix struggle

Use the parseInt Function with a Radix struggle
0

#1

Tell us what’s happening:
I don’t understand! How can I fix it?

Your code so far


function convertToInteger(str) {
  var convertToInterger = parseInt(str);
  return parseInt(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/69.0.3497.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/use-the-parseint-function-with-a-radix


#2

@zuc0n Both lines of your code do the same thing, so you’ll only need one of them. Then, your parseInt syntax isn’t correct for binary.

Here’s the example in the instructions to convert the string 11 to binary (11 is 3 in binary):

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

So, if one wanted to convert another string to binary, they could do something like:

var a = parseInt("<any_number_here>", 2)

Does that help?