* chore(learn): audit basic algorithm scripting * chore(learn): audit basic data structures * chore(learn): audit basic javascript * chore(learn): audit debugging * chore(learn): audit es6 * chore(learn): audit functional programming * chore(learn): audit intermidate algorithms * chore(learn): audit js projects * chore(learn): audit object oriented programming * chore(learn): audit regex * fix(learn): remove stray . * fix(learn): string to code * fix(learn): missed some * fix(learn): clarify strings Based on Randy's feedback, clarifies string instances where quotes were removed in favour of back ticks. * fix: apply suggestions - thanks Randy! :) Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: non-suggestion comments * chore(learn): remove comments from codes Removes the comments from the description and instruction code blocks to ensure that all relevant information is translatable. * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: revert crowdin fix * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-arrays.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * fix: Apply suggestions from code review Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * chore: change voice * fix: Christopher Nolan * fix: expressions would evaluate * fix: will -> would * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> * fix: to work to push * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.md Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Shaun Hamilton <51722130+ShaunSHamilton@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
2.1 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7daa367417b2b2512b6c | Combine an Array into a String Using the join Method | 1 | 18221 | combine-an-array-into-a-string-using-the-join-method |
--description--
The 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(" ");
str
would have a value of the string Hello World
.
--instructions--
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.
--hints--
Your code should use the join
method.
assert(code.match(/\.join/g));
Your code should not use the replace
method.
assert(!code.match(/\.?[\s\S]*?replace/g));
sentensify("May-the-force-be-with-you")
should return a string.
assert(typeof sentensify('May-the-force-be-with-you') === 'string');
sentensify("May-the-force-be-with-you")
should return the string May the force be with you
.
assert(sentensify('May-the-force-be-with-you') === 'May the force be with you');
sentensify("The.force.is.strong.with.this.one")
should return the string The force is strong with this one
.
assert(
sentensify('The.force.is.strong.with.this.one') ===
'The force is strong with this one'
);
sentensify("There,has,been,an,awakening")
should return the string There has been an awakening
.
assert(
sentensify('There,has,been,an,awakening') === 'There has been an awakening'
);
--seed--
--seed-contents--
function sentensify(str) {
// Only change code below this line
// Only change code above this line
}
sentensify("May-the-force-be-with-you");
--solutions--
function sentensify(str) {
// Only change code below this line
return str.split(/\W/).join(' ');
// Only change code above this line
}