1function binaryAgent(str) {
2
3var newBin = str.split(" ");
4var binCode = [];
5
6for (i = 0; i < newBin.length; i++) {
7 binCode.push(String.fromCharCode(parseInt(newBin[i], 2)));
8 }
9return binCode.join("");
10}
11binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100');
12//translates to "Aren't"
13
1function binaryAgent(str) {
2 let bytes = str.split(' ');
3 let output = '';
4
5 for (let k = 0; k < bytes.length; k++){
6 output += String.fromCharCode(convertToDecimal(bytes[k]));
7 }
8
9 return output;
10}
11
12function convertToDecimal(byte) {
13 let result = 0;
14
15 byte = byte.split('');
16
17 byte.reverse();
18
19 for (let a = 0; a < byte.length; a++){
20 if (byte[a] === '1'){
21 result += 2 ** a;
22 }
23 }
24
25 return result;
26}
27
28binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
29