Files
.github
api-server
client
config
curriculum
docs
guide
arabic
chinese
english
3d
accessibility
agile
algorithms
android-development
angular
apache
aspnet
bash
blender
blockchain
bootstrap
bsd-os
bulma
c
canvas
certifications
apis-and-microservices
coding-interview-prep
data-visualization
front-end-libraries
information-security-and-quality-assurance
javascript-algorithms-and-data-structures
basic-algorithm-scripting
basic-data-structures
basic-javascript
debugging
es6
functional-programming
add-elements-to-the-end-of-an-array-using-concat-instead-of-push
apply-functional-programming-to-convert-strings-to-url-slugs
avoid-mutations-and-side-effects-using-functional-programming
combine-an-array-into-a-string-using-the-join-method
index.md
combine-two-arrays-using-the-concat-method
implement-map-on-a-prototype
implement-the-filter-method-on-a-prototype
introduction-to-currying-and-partial-application
learn-about-functional-programming
pass-arguments-to-avoid-external-dependence-in-a-function
refactor-global-variables-out-of-functions
remove-elements-from-an-array-using-slice-instead-of-splice
return-a-sorted-array-without-changing-the-original-array
return-part-of-an-array-using-the-slice-method
sort-an-array-alphabetically-using-the-sort-method
split-a-string-into-an-array-using-the-split-method
understand-functional-programming-terminology
understand-the-hazards-of-using-imperative-code
use-the-every-method-to-check-that-every-element-in-an-array-meets-a-criteria
use-the-filter-method-to-extract-data-from-an-array
use-the-map-method-to-extract-data-from-an-array
use-the-reduce-method-to-analyze-data
use-the-some-method-to-check-that-any-elements-in-an-array-meet-a-criteria
index.md
intermediate-algorithm-scripting
javascript-algorithms-and-data-structures-projects
object-oriented-programming
regular-expressions
index.md
responsive-web-design
index.md
chef
clojure
cloud-development
codeigniter
computational-genomics
computer-hardware
computer-science
containers
cplusplus
csharp
css
d3
data-science-tools
dc
design-patterns
designer-tools
developer-ethics
developer-tools
devops
dns
docker
documentation
drupal
electron
elixir
elm
erlang
fsharp
game-development
gatsbyjs
git
go
graphql
groovy
haskell
haxe
hibernate
html
ionic
java
javascript
joomla
jquery
julia
kotlin
laravel
linux
logic
machine-learning
mariadb
mathematics
meta
miscellaneous
mobile-app-development
mongodb
natural-language-processing
neovim
network-engineering
nginx
nodejs
optical-alignment
php
powershell
product-design
progressive-web-apps
puppet
python
r
raspberry-pi
react
react-native
redux
rest-api
robotics
rt-os
ruby
rust
sass
security
semantic-ui
software-engineering
sql
ssh
svg
svn
swift
tailwindcss
terminal-commandline
tomcat
tools
typescript
typography
user-experience-design
user-experience-research
vagrant
vim
virtualbox
visual-design
voice
vue
vue-cli
web-augmented-reality
web-components
web-performance
web-virtual-reality
wordpress
working-in-tech
xml
portuguese
russian
spanish
mock-guide
tools
.editorconfig
.eslintignore
.eslintrc.json
.gitattributes
.gitignore
.node-inspectorrc
.prettierrc
.snyk
.travis.yml
.vcmrc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile.tests
LICENSE.md
README.french.md
README.italian.md
README.md
change_volumes_owner.sh
docker-compose-shared.yml
docker-compose.tests.yml
docker-compose.yml
lerna.json
netlify.toml
package-lock.json
package.json
sample.env

31 lines
1.1 KiB
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Combine an Array into a String Using the join Method
---
## Combine an Array into a String Using the join Method
### Problem Explanation
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.
#### Relevant Links:
- [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)
### Hint1
You may need to convert the string to an array first.
### Hint2
You may need to use regular expression to split the string.
### Solution:
```javascript
function sentensify(str) {
// Add your code below this line
return str.split(/\W/).join(' ');
// Add your code above this line
}
sentensify("May-the-force-be-with-you");
```