Check for Partial Match in an Array
<p>I have a JavaScript array that contains some words that cannot be used when requesting user accounts to be created.</p>

<p>I am trying to loop over the accounts requested and check them against a word filter. If they contain any of the words, the value is moved to an array of "Invalid Accounts".</p>

<pre><code>// Create our arrays
var blacklist = ["admin", "webform", "spoof"];
var newAccounts = ["admin1@google.com", "interweb@google.com", "puppy@google.com"];
var invalidAccounts = [];

// I need to check if any of the new accounts have matches to those in the blacklist. 
// admin1@google.com would need to be pushed into the invalidAccounts array because it 
// contains the word admin. Although interweb contains the word web, it does not contain 
// the full word, webform, so should be ignored.

// Loop over the blacklist array
for(var x = 0; x &lt; blacklist.length; x++){
  if(blacklist[x].indexOf(newAccounts) &gt; -1){
    alert(blacklist[x] + " is in the blacklist array");
    // Push the newAccounts value into the invalidAccounts array since it contains
    // a blacklist word.
  } else {
    alert('no matches');
  }
}
</code></pre>

<p>What do I need to change in the above code to have it match the partial strings such as mentioned?</p>

<p>Fiddle of above code: <a href="https://jsfiddle.net/1qwze81o/" rel="nofollow">https://jsfiddle.net/1qwze81o/</a></p>