Всем привет, помощь нужна, смотрите Есть массив данных Необходимо вывести ряд слов, у которых первая буква будет совпадать с последней буквой последующего слова, и так прогнать все слова, кто поможет накину
Я создал массив, через цикл прогнал его, и условие создал " array[a][0] == array[b].chartAt(0){ console.log(array[b])
________ посл. ред. 20.05.2021 в 12:41; всего 3 раз(а); by Ржавый
// Поддержка на старых браузерах if (!String.prototype.endsWith) { Object.defineProperty(String.prototype, 'endsWith', { value: function(searchString, position) { var subjectString = this.toString(); if (position === undefined || position > subjectString.length) { position = subjectString.length; } position -= searchString.length; var lastIndex = subjectString.indexOf(searchString, position); return lastIndex !== -1 && lastIndex === position; } }); } var words = ['test', 'testing', 'the test']; var words_includes = []; for (var index = 0; index <= words.length - 2; index++) { if (words[index + 1].endsWith(words[index].slice(0, 1))) { words_includes.push(words[ index ]); } } console.log(words_includes);
________ посл. ред. 20.05.2021 в 12:07; всего 1 раз(а); by mrcatoff