2021-06-15 00:49:18 -07:00
---
id: 587d7daa367417b2b2512b6c
2021-07-21 20:53:20 +05:30
title: Transformar um array em uma string usando o método join
2021-06-15 00:49:18 -07:00
challengeType: 1
forumTopicId: 18221
dashedName: combine-an-array-into-a-string-using-the-join-method
---
# --description--
2021-07-16 11:03:16 +05:30
O método `join` é usado para juntar os elementos de um array, resultando em uma string. Ele recebe um delimitador como argumento, que é usado para conectar os elementos na string.
2021-06-15 00:49:18 -07:00
2021-07-26 23:39:21 +09:00
Exemplo:
2021-06-15 00:49:18 -07:00
```js
2021-10-27 15:10:57 +00:00
const arr = ["Hello", "World"];
const str = arr.join(" ");
2021-06-15 00:49:18 -07:00
```
2021-07-16 11:03:16 +05:30
O valor de `str` é `Hello World` .
2021-06-15 00:49:18 -07:00
# --instructions--
2021-07-30 23:57:21 +09:00
Use o método `join` (entre outros) dentro da função `sentensify` para criar uma frase a partir das palavras da string `str` . A função deve retornar uma string. Por exemplo, `I-like-Star-Wars` deve ser convertido para `I like Star Wars` . Não use o método `replace` neste desafio.
2021-06-15 00:49:18 -07:00
# --hints--
2021-07-16 11:03:16 +05:30
Você deve usar o método `join` .
2021-06-15 00:49:18 -07:00
```js
assert(code.match(/\.join/g));
```
2021-07-16 11:03:16 +05:30
Você não deve usar o método `replace` .
2021-06-15 00:49:18 -07:00
```js
assert(!code.match(/\.?[\s\S]*?replace/g));
```
2021-07-16 11:03:16 +05:30
`sentensify("May-the-force-be-with-you")` deve retornar uma string.
2021-06-15 00:49:18 -07:00
```js
assert(typeof sentensify('May-the-force-be-with-you') === 'string');
```
2021-07-16 11:03:16 +05:30
`sentensify("May-the-force-be-with-you")` deve retornar a string `May the force be with you` .
2021-06-15 00:49:18 -07:00
```js
assert(sentensify('May-the-force-be-with-you') === 'May the force be with you');
```
2021-07-16 11:03:16 +05:30
`sentensify("The.force.is.strong.with.this.one")` deve retornar a string `The force is strong with this one` .
2021-06-15 00:49:18 -07:00
```js
assert(
sentensify('The.force.is.strong.with.this.one') ===
'The force is strong with this one'
);
```
2021-07-16 11:03:16 +05:30
`sentensify("There,has,been,an,awakening")` deve retornar a string `There has been an awakening` .
2021-06-15 00:49:18 -07:00
```js
assert(
sentensify('There,has,been,an,awakening') === 'There has been an awakening'
);
```
# --seed--
## --seed-contents--
```js
function sentensify(str) {
// Only change code below this line
// Only change code above this line
}
2021-10-27 15:10:57 +00:00
2021-06-15 00:49:18 -07:00
sentensify("May-the-force-be-with-you");
```
# --solutions--
```js
function sentensify(str) {
return str.split(/\W/).join(' ');
}
```