Created
April 4, 2016 03:22
-
-
Save mindplace/163fe26593fd000990dc95b860d02b31 to your computer and use it in GitHub Desktop.
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 BinaryConverter(binNum) { | |
var numArray = binNum.toString().split("").reverse(); | |
var number = 0; | |
for (var i=0; i < numArray.length; i++) { | |
var num = parseInt(numArray[i]); | |
var location = Math.pow(2, i); | |
number += num * location; | |
} | |
return number; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment