# Use the parseInt Function with a Radix help

Tell us what’s happening:
convertToInteger(“10011”) should return 19
convertToInteger(“111001”) should return 57
How to return 19, 57?
I don’t understand.

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

}

convertToInteger("10011");
``````

User Agent is: `Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36`.

`parseInt` needs a second parameter, take a look at the documentation:

`parseInt(string, radix);`

function convertToInteger(str) {
var a = parseInt(str);
if(isNaN(parseInt)) {return 0}
return parseInt * 100;
}

convertToInteger(“10011”);

question:
convertToInteger(“10011”) should return 19
convertToInteger(“111001”) should return 57
convertToInteger(“JamesBond”) should return NaN

if enter console.log(converToIntger(parseInt));can sumbit??
still don’t understand.

it is have solve it.

You don’t need all those things, `parseInt()` itself returns `NaN` if the thing passed is not a number

And you don’t need to multiply by `100` - the number from `parseInt` is already the number you need

1 Like