const foundMatches = formattedTest.match(new RegExp(term, 'gi')) const termFrequency = foundMatches ? foundMatches.length : 0