Guest User

Untitled

a guest
Jun 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. // Intermediate Algorithm Scripting: Binary Agents
  2.  
  3. // Return an English translated sentence of the passed binary string.
  4. // The binary string will be space separated.
  5.  
  6. function binaryAgent(str) {
  7. return str.split(" ").map(letter => String.fromCharCode(parseInt(letter,2).toString())).join("");
  8. }
  9.  
  10. 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!?"
  11.  
  12. binaryAgent("01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001"); // "I love FreeCodeCamp!"
Add Comment
Please, Sign In to add comment