2021-06-15 07:49:18 +00:00
|
|
|
---
|
|
|
|
id: a8d97bd4c764e91f9d2bda01
|
2021-07-21 15:23:20 +00:00
|
|
|
title: Transformar de binário em string
|
2021-06-15 07:49:18 +00:00
|
|
|
challengeType: 5
|
|
|
|
forumTopicId: 14273
|
|
|
|
dashedName: binary-agents
|
|
|
|
---
|
|
|
|
|
|
|
|
# --description--
|
|
|
|
|
2021-07-16 05:33:16 +00:00
|
|
|
Retorne uma frase traduzida em Inglês da string binária passada.
|
2021-06-15 07:49:18 +00:00
|
|
|
|
2021-07-16 05:33:16 +00:00
|
|
|
A string binária será separada por espaço.
|
2021-06-15 07:49:18 +00:00
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
2021-07-16 05:33:16 +00:00
|
|
|
`binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111")` deve retornar a string `Aren't bonfires fun!?`
|
2021-06-15 07:49:18 +00:00
|
|
|
|
|
|
|
```js
|
|
|
|
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!?"
|
|
|
|
);
|
|
|
|
```
|
|
|
|
|
2021-07-16 05:33:16 +00:00
|
|
|
`binaryAgent("01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001")` deve retornar a string `I love FreeCodeCamp!`
|
2021-06-15 07:49:18 +00:00
|
|
|
|
|
|
|
```js
|
|
|
|
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!'
|
|
|
|
);
|
|
|
|
```
|
|
|
|
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```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");
|
|
|
|
```
|
|
|
|
|
|
|
|
# --solutions--
|
|
|
|
|
|
|
|
```js
|
|
|
|
function binaryAgent(str) {
|
|
|
|
return str.split(' ').map(function(s) { return parseInt(s, 2); }).map(function(b) { return String.fromCharCode(b);}).join('');
|
|
|
|
}
|
|
|
|
```
|