2018-10-04 14:37:37 +01:00
---
id: a8d97bd4c764e91f9d2bda01
title: Binary Agents
isRequired: true
challengeType: 5
2019-07-31 11:32:23 -07:00
forumTopicId: 14273
2018-10-04 14:37:37 +01:00
---
## Description
< section id = 'description' >
Return an English translated sentence of the passed binary string.
The binary string will be space separated.
Remember to use < a href = 'http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514' target = '_blank' > Read-Search-Ask< / a > if you get stuck. Try to pair program. Write your own code.
< / section >
## Instructions
< section id = 'instructions' >
< / section >
## Tests
< section id = 'tests' >
```yml
tests:
2018-10-20 21:02:47 +03:00
- text: < code > binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111")</ code > should return "Aren& #39 ; t bonfires fun!?"
2019-07-24 01:56:38 -07:00
testString: assert.deepEqual(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!?");
2018-10-04 14:37:37 +01:00
- text: < code > binaryAgent("01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001")</ code > should return "I love FreeCodeCamp!"
2019-07-24 01:56:38 -07:00
testString: assert.deepEqual(binaryAgent('01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001'), "I love FreeCodeCamp!");
2018-10-04 14:37:37 +01:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
function binaryAgent(str) {
return str;
}
binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
function binaryAgent(str) {
return str.split(' ').map(function(s) { return parseInt(s, 2); }).map(function(b) { return String.fromCharCode(b);}).join('');
}
```
< / section >