Skip to content

Instantly share code, notes, and snippets.

@eday69
Created June 15, 2018 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eday69/5ab156237080aaea96c6da497e073309 to your computer and use it in GitHub Desktop.
Save eday69/5ab156237080aaea96c6da497e073309 to your computer and use it in GitHub Desktop.
freeCodeCamp Intermediate Algorithm Scripting: Binary Agents
// Intermediate Algorithm Scripting: Binary Agents
// Return an English translated sentence of the passed binary string.
// The binary string will be space separated.
function binaryAgent(str) {
return str.split(" ").map(letter => String.fromCharCode(parseInt(letter,2).toString())).join("");
}
binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111"); // "Aren't bonfires fun!?"
binaryAgent("01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001"); // "I love FreeCodeCamp!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment