* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
2.4 KiB
2.4 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7daa367417b2b2512b6c | Combine an Array into a String Using the join Method | 1 | 使用join方法将Array组合成String |
Description
join
方法用于将数组的元素连接在一起以创建字符串。它需要一个用于分隔字符串中数组元素的分隔符的参数。这是一个例子: var arr = [“你好”,“世界”];
var str = arr.join(“”);
//将str设置为“Hello World”
Instructions
sentensify
函数内的join
方法(以及其他方法)从字符串str
的单词创建一个句子。该函数应返回一个字符串。例如,“我喜欢星球大战”将被转换为“我喜欢星球大战”。对于此挑战,请勿使用replace
方法。 Tests
tests:
- text: 您的代码应使用<code>join</code>方法。
testString: assert(code.match(/\.join/g));
- text: 您的代码不应使用<code>replace</code>方法。
testString: assert(!code.match(/\.replace/g));
- text: <code>sentensify("May-the-force-be-with-you")</code>应该返回一个字符串。
testString: assert(typeof sentensify("May-the-force-be-with-you") === "string");
- text: <code>sentensify("May-the-force-be-with-you")</code>应该返回<code>"May the force be with you"</code> 。
testString: assert(sentensify("May-the-force-be-with-you") === "May the force be with you");
- text: <code>sentensify("The.force.is.strong.with.this.one")</code>应该返回<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");
- text: '<code>sentensify("There,has,been,an,awakening")</code>应该回归<code>"There has been an awakening"</code> 。'
testString: assert(sentensify("There,has,been,an,awakening") === "There has been an awakening");
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