2018-10-12 15:37:13 -04:00
---
title: Combine an Array into a String Using the join Method
---
2019-07-24 00:59:27 -07:00
# Combine an Array into a String Using the join Method
2018-10-12 15:37:13 -04:00
2019-07-24 00:59:27 -07:00
---
## Problem Explanation
2018-10-12 15:37:13 -04:00
Use the `join` method (among others) inside the `sentensify` function to make a sentence from the words in the string `str` . The function should return a string. For example, "I-like-Star-Wars" would be converted to "I like Star Wars". For this challenge, do not use the `replace` method.
2019-07-24 00:59:27 -07:00
#### Relevant Links
2018-10-12 15:37:13 -04:00
- [Array.prototype.join() ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join )
- [String.prototype.split() ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split )
- [Regular Expressions ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions )
2019-07-24 00:59:27 -07:00
---
## Hints
2018-10-12 15:37:13 -04:00
### Hint1
You may need to convert the string to an array first.
### Hint2
You may need to use regular expression to split the string.
2019-07-24 00:59:27 -07:00
---
## Solutions
< details > < summary > Solution 1 (Click to Show/Hide)< / summary >
2018-10-12 15:37:13 -04:00
```javascript
function sentensify(str) {
// Add your code below this line
2019-07-24 00:59:27 -07:00
return str.split(/\W/).join(" ");
2018-10-12 15:37:13 -04:00
// Add your code above this line
}
sentensify("May-the-force-be-with-you");
```
2019-07-24 00:59:27 -07:00
< / details >