parseInt isnt working

Tell us what’s happening:

Your code so far


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

convertToInteger("10011");
convertToInteger("111001");
convertToInteger("JamesBond");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 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/

You’re missing your radix…

convertToInteger(“10011”, ???);

Is it like this?

function convertToInteger(str, radix) {

return parseInt(str,radix);
}

convertToInteger(“10011”,19);
convertToInteger(“111001”, 57);
convertToInteger(“JamesBond”);

radix is the base of the number you wish to parse. A string of “1010101” is binary, aka base 2, so the radix would be 2.

A string like “JamesBond” would be valid base36, but I suspect you’re supposed to treat is as base10 and get a NaN result from parseInt.

Use parseInt() in the convertToInteger function so it converts a binary number to an integer and returns it.

You need to make it all binary. Also, don’t add new parameters to the function, the tests call the function with just one argument