I've got an array of words that I want to find in a String. I'm doing this in JavaScript,

```js
var lotsOfText = "blahmehfoobar hello random stuff here blahblah blegh coding stackover flow computersc ience";

var textToFind = ["blah", "random stuff", "stackover flow comput"];
var counter = 0;

for (var i = 0; i < textToFind.length; i++) {
  var text = textToFind[i];
  for (var j = 0; j < lotsOfText.length; j++) {
    if (text.charAt(0) === lotsOfText.charAt(j)) {
      if (text === lotsOfText.substring(j, text.length)) {
        counter++;
        j = text.length - 1;
      }
    }
  }
}

console.log(counter);
```

Right now, the counter = 1

I don't know where its going wrong.

Also, is there a better/faster way of doing this? Maybe something that doesn't require two for loops and multiple passes through the string text?

Edit: I want to find ALL occurrences of each word in the string. So, as it is now, counter should return 5