Строка заканчивается подстрокой const endsWithSubstring = (text, word) => { for (let i in word) { const substr = word.slice(0, i + 1); if (text.endsWith(substr)) return substr; } return undefined; };JavaScriptCopy endsWithSubstring('Lorem ipsum dolor sit amet<br /', '<br />'); // '<br /'JavaScriptCopy Текст и строки JavaScript