Created
March 22, 2023 14:09
-
-
Save periakteon/810e08fdd6cc3a6fc44cd81d0c3f3632 to your computer and use it in GitHub Desktop.
FreeCodeCamp: Use the parseInt Function with a Radix (Solution)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convertToInteger(str) { | |
return parseInt(str, 2); | |
} | |
console.log(convertToInteger("10011")); | |
// 19 | |
console.log(convertToInteger("111001")); | |
// 57 | |
console.log(convertToInteger("James Bond")); | |
// NaN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment