Created
February 18, 2018 23:28
-
-
Save escottalexander/b93de741a089fe8fe5595e00a4fcfa70 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 binaryAgent(str) { | |
var binArr = []; | |
str = str.split(" "); | |
for (var i = 0; i < str.length; i++) { | |
binArr.push(String.fromCharCode(parseInt(str[i], 2))); | |
} | |
str = binArr.join(""); | |
console.log(str) | |
return str; | |
} | |
function convertToBinary(str) { | |
var binArr = []; | |
var arr = str.split(""); | |
for (var i = 0; i < arr.length; i++) { | |
binArr.push(str.charCodeAt(i).toString(2)); | |
} | |
str = binArr.join(" "); | |
console.log(str); | |
return str; | |
} | |
//convertToBinary("Enter text here and uncomment") | |
//binaryAgent("Enter binary here and uncomment to reveal the meaning") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment