I have a JavaScript array that contains some words that cannot be used when requesting user accounts to be created.
I am trying to loop over the accounts requested and c
A solution using javascript array native functions:
var invalidAccounts = newAccounts.filter(function(account){ // we need to filter accounts
return blacklist.some(function(word){ // and return those that have any of the words in the text
return account.indexOf(word) != -1
})
});
More info on: Array.filter and Array.some