join
يستخدم طريقة للانضمام إلى عناصر من مجموعة معا لخلق سلسلة. يستغرق وسيطة عن المحدد الذي يتم استخدامه لفصل عناصر الصفيف في السلسلة. إليك مثال على ذلك: var arr = ["Hello"، "World"]؛
var str = arr.join ("")؛
// يعين str إلى "Hello World"
join
(من بين آخرين) داخل الدالة sentensify
لإنشاء جملة من الكلمات في str
السلسلة. يجب على الدالة إرجاع سلسلة. على سبيل المثال ، سيتم تحويل "I-like-Star-Wars" إلى "I like Star Wars". لهذا التحدي ، لا تستخدم طريقة replace
. join
الأسلوب.
testString: 'assert(code.match(/\.join/g), "Your code should use the join
method.");'
- text: يجب ألا تستخدم الشفرة طريقة replace
.
testString: 'assert(!code.match(/\.replace/g), "Your code should not use the replace
method.");'
- text: sentensify("May-the-force-be-with-you")
يجب إرجاع سلسلة.
testString: 'assert(typeof sentensify("May-the-force-be-with-you") === "string", "sentensify("May-the-force-be-with-you")
should return a string.");'
- text: sentensify("May-the-force-be-with-you")
يجب أن ترجع "May the force be with you"
.
testString: 'assert(sentensify("May-the-force-be-with-you") === "May the force be with you", "sentensify("May-the-force-be-with-you")
should return "May the force be with you"
.");'
- text: sentensify("The.force.is.strong.with.this.one")
يجب أن ترجع "The force is strong with this one"
.
testString: 'assert(sentensify("The.force.is.strong.with.this.one") === "The force is strong with this one", "sentensify("The.force.is.strong.with.this.one")
should return "The force is strong with this one"
.");'
- text: 'sentensify("There,has,been,an,awakening")
يجب أن تعود "There has been an awakening"
.'
testString: 'assert(sentensify("There,has,been,an,awakening") === "There has been an awakening", "sentensify("There,has,been,an,awakening")
should return "There has been an awakening"
.");'
```