DEV: tiny refactor in watched words (#12969)

DEV: tiny refactor in watched words (#12969)

diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/watched-words-replace.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/watched-words-replace.js
index 7c358d1..c44d5cf 100644
--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/watched-words-replace.js
+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/watched-words-replace.js
@@ -11,16 +11,14 @@ function findAllMatches(text, matchers, useRegExp) {
 
   if (useRegExp) {
     const maxMatches = 100;
-    let index = 0;
+    let count = 0;
 
     matchers.forEach((matcher) => {
       let match;
       while (
         (match = matcher.pattern.exec(text)) !== null &&
-        index < maxMatches
+        count++ < maxMatches
       ) {
-        index++;
-
         matches.push({
           index: match.index,
           text: match[0],

GitHub sha: 82ecd9fd

This commit appears in #12969 which was approved by eviltrout and ZogStriP. It was merged by pmusaraj.