.github
api-server
client
config
curriculum
challenges
_meta
arabic
chinese
english
01-responsive-web-design
02-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.english.md
apply-functional-programming-to-convert-strings-to-url-slugs.english.md
avoid-mutations-and-side-effects-using-functional-programming.english.md
combine-an-array-into-a-string-using-the-join-method.english.md
combine-two-arrays-using-the-concat-method.english.md
implement-map-on-a-prototype.english.md
implement-the-filter-method-on-a-prototype.english.md
introduction-to-currying-and-partial-application.english.md
learn-about-functional-programming.english.md
pass-arguments-to-avoid-external-dependence-in-a-function.english.md
refactor-global-variables-out-of-functions.english.md
remove-elements-from-an-array-using-slice-instead-of-splice.english.md
return-a-sorted-array-without-changing-the-original-array.english.md
return-part-of-an-array-using-the-slice-method.english.md
sort-an-array-alphabetically-using-the-sort-method.english.md
split-a-string-into-an-array-using-the-split-method.english.md
understand-functional-programming-terminology.english.md
understand-the-hazards-of-using-imperative-code.english.md
use-the-every-method-to-check-that-every-element-in-an-array-meets-a-criteria.english.md
use-the-filter-method-to-extract-data-from-an-array.english.md
use-the-map-method-to-extract-data-from-an-array.english.md
use-the-reduce-method-to-analyze-data.english.md
use-the-some-method-to-check-that-any-elements-in-an-array-meet-a-criteria.english.md
intermediate-algorithm-scripting
javascript-algorithms-and-data-structures-projects
object-oriented-programming
regular-expressions
03-front-end-libraries
04-data-visualization
05-apis-and-microservices
06-information-security-and-quality-assurance
08-coding-interview-prep
09-certificates
portuguese
russian
spanish
formattingConversion
math-challenges
requiresTests
schema
test
.babelrc
.editorconfig
.npmignore
.travis.yml
CHANGELOG.md
LICENSE.md
commitizen.config.js
commitlint.config.js
create-challenge-bundle.js
getChallenges.js
gulpfile.js
index.js
lib.js
md-translation.js
package-entry.js
package-lock.json
package.json
utils.js
docs
guide
mock-guide
tools
.editorconfig
.eslintignore
.eslintrc.json
.gitattributes
.gitignore
.node-inspectorrc
.prettierrc
.snyk
.travis.yml
.vcmrc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE.md
README.french.md
README.italian.md
README.md
docker-compose-shared.yml
docker-compose.yml
lerna.json
netlify.toml
package-lock.json
package.json
sample.env
* fix(curriculum): tests quotes * fix(curriculum): fill seed-teardown * fix(curriculum): fix tests and remove unneeded seed-teardown
2.8 KiB
2.8 KiB
id, title, challengeType
id | title | challengeType |
---|---|---|
587d7daa367417b2b2512b6c | Combine an Array into a String Using the join Method | 1 |
Description
join
method is used to join the elements of an array together to create a string. It takes an argument for the delimiter that is used to separate the array elements in the string.
Here's an example:
var arr = ["Hello", "World"];
var str = arr.join(" ");
// Sets str to "Hello World"
Instructions
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.
Tests
tests:
- text: Your code should use the <code>join</code> method.
testString: assert(code.match(/\.join/g), 'Your code should use the <code>join</code> method.');
- text: Your code should not use the <code>replace</code> method.
testString: assert(!code.match(/\.replace/g), 'Your code should not use the <code>replace</code> method.');
- text: <code>sentensify("May-the-force-be-with-you")</code> should return a string.
testString: assert(typeof sentensify("May-the-force-be-with-you") === "string", '<code>sentensify("May-the-force-be-with-you")</code> should return a string.');
- text: <code>sentensify("May-the-force-be-with-you")</code> should return <code>"May the force be with you"</code>.
testString: assert(sentensify("May-the-force-be-with-you") === "May the force be with you", '<code>sentensify("May-the-force-be-with-you")</code> should return <code>"May the force be with you"</code>.');
- text: <code>sentensify("The.force.is.strong.with.this.one")</code> should return <code>"The force is strong with this one"</code>.
testString: assert(sentensify("The.force.is.strong.with.this.one") === "The force is strong with this one", '<code>sentensify("The.force.is.strong.with.this.one")</code> should return <code>"The force is strong with this one"</code>.');
- text: <code>sentensify("There,has,been,an,awakening")</code> should return <code>"There has been an awakening"</code>.
testString: assert(sentensify("There,has,been,an,awakening") === "There has been an awakening", '<code>sentensify("There,has,been,an,awakening")</code> should return <code>"There has been an awakening"</code>.');
Challenge Seed
function sentensify(str) {
// Add your code below this line
// Add your code above this line
}
sentensify("May-the-force-be-with-you");
Solution
// solution required