Created
May 16, 2015 15:11
-
-
Save montyanderson/992cc428d5b88fab4791 to your computer and use it in GitHub Desktop.
This file contains 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 binarytodecimal(binary) { | |
var decimal = 0; | |
for(var i = 0; i < binary.length; i++) { | |
if(binary.charAt(binary.length - i -1) == "1") { | |
decimal += Math.pow(2, i); | |
} | |
} | |
return decimal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment