Use parseInt() in the convertToInteger function so it converts a binary number to an integer and returns it. code example
Example: Use parseInt() in the convertToInteger function so it converts a binary number to an integer and returns it.
function convertToInteger(str) {
return parseInt(str, 2);
}