Link Search Menu Expand Document

Use the parseInt Function with a Radix

Summary

  • parseInt() accepts a second argument that allows the base of the number (2-36) to be specified.

Final Code

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

convertToInteger("10011");