join
используется для объединения элементов массива вместе для создания строки. Он принимает аргумент для разделителя, который используется для разделения элементов массива в строке. Вот пример: var arr = ["Hello", "World"];
var str = arr.join ("");
// Устанавливает str для «Hello World»
join
(среди других) внутри функции sentensify
чтобы сделать предложение из слов в строке str
. Функция должна возвращать строку. Например, «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"
.");'
```