I want to mark some repeated sentences from a text area input paragraph. I tried the below code but it's not working.
highlightRepeated(str) {
// Split the string into an array of sentences
const sentences = str.split(".");
// Create a variable to store the repeated sentences
let repeated = [];
// Iterate over the array of sentences
for (let i = 0; i < sentences.length; i++) {
const sentence = sentences[i].trim();
// If the sentence has already been added to the repeated array, highlight it
if (repeated.includes(sentence)) {
sentences[i] = `<mark>${sentence}</mark>`;
} else {
// Otherwise, add it to the repeated array
repeated.push(sentence);
}
}
// Return the modified string
return sentences.join(".");
},