title: Is this a bug in Google apps script?
body: <p>I was working on the "Create an Editing Tool" project on the Google Applied Digital Skills website. When I was creating my editing tool, I came across two glitches. One is that the word "som" is highlighted, even though it isn't in the array. The other is that the word "heroi" is highlighted. This definitely looks like a bug, especially because "heroi" is highlighted in the same color as "hero." </p>
  
  <p><img src="https://i.stack.imgur.com/VYXuG.png" alt="Screenshot of Document"></p>
  
  <p>Does anyone know if this is an error I made or if it's a glitch?
  Here's the code:</p>
  
  <pre><code>    function findText(item) {
  
          //choose a random color as the background
  
          //credit to James from https://stackoverflow.com/questions/1484506/random-color-generator
  
          var background = '#' + (Math.random().toString(16) + "000000").substring(2, 8)
  
          //log the item being found to make sure it is being searched for
  
          Logger.log(item)
  
          //shows the computer what the search result is
  
          var searchResult
  
          //find the search result
  
          searchResult = DocumentApp.getActiveDocument().getBody().findText(item)
  
          //put it in the log
  
          Logger.log(searchResult)
  
          //loop until item is no longer found
  
          while (searchResult !== null) {
  
              //change the background color for a set space, which is when item is first used.
  
              searchResult.getElement().asText().setBackgroundColor(searchResult.getStartOffset(), searchResult.getEndOffsetInclusive(), background)
  
              //find the text again
  
              searchResult = DocumentApp.getActiveDocument().getBody().findText(item, searchResult)
  
              //end of the loop
  
          }
  
  
  
      }
  
      function highlightProblem() {
  
          //array showing all values of item
  
          var words = ["very", "Very", "totally", "Totally", "heroic", "Heroic", "really", "Really", "so ", "so. ", "so, ", "So ", "So. ", "So, ", "its", "Its", "good", "Good", "examples", "Examples", "hero ", "hero. ", "hero, ", "Hero ", "Hero. ", "Hero, "]
  
          //find each item in the array
  
          words.forEach(findText)
  
      }
  </code></pre>