I have tried finding a solution with/out the radix. When I console.log with base 2, I am getting 19 but my test still returns an error like so;
function convertToInteger(str, radix) {
var parsed = parseInt(str, radix)
if (isNaN(parsed)) {
return NaN;
}
return parsed;
}
console.log(convertToInteger("10011", 2));
returns 19 before running the test.
and it returns this;
// running tests
convertToInteger("10011") should return 19
convertToInteger("111001") should return 57
// tests completed
after running the test.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0.
Look at this line, what should radix be? It can’t be a parameter of the function because the function calls in the tests have only one argument, so you need to actually put a value there instead of a variable
If you use parseInt correctly, it will return NaN on its own without needing other lines of code, as the value returned from parseInt would be NaN
parseInt() method will return NaN if string argument is not number so you don’t need to test the result.
about radix, either you put 2 as parameter in parseInt() method or create a var radix = 2