Use the parseInt Function with a Radix prb

Tell us what’s happening:
where I can use the radix element ? because in the function they only mention the str.

Your code so far


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

convertToInteger("10011");

Your browser information:

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

@sojib-bd,

in the lesson they are referring to the radix base that can be an optional second argument to the parseInt method.

what else should i write in the code?

I have most of it correct but cant seem to return 19 and 56 i need help.

This is my code so far:

function convertToInteger(str, radix) {
    var a = parseInt(str, radix);
    return a;

    
}

convertToInteger("10011");

@Duwayne16,

I would suggest you try debugging your code, with console.logs, and see where your code falls short. After that, if you still can’t figure out the issue, post again and we will try to help.

Hey man still not getting it.

What did you try? Did you add console.log statements? What did you see? Give us some information.

Yes i console.log but done it several times to see my mistake but helped a lot thanks.

Awesome that you solved the problem. Care to elaborate so you can help people who will have the same issue?

Yes please, @Duwayne16, could you elaborate?

I am stuck on this challenge too, actually when I try to use the convertToInteger to get the result as 57, with 111001, it does work on Chrome’s console, but when I try on FCC it won’t…

Any tips please?