title: How do I remove/filter specific items from an array?
body: <p>I am writing a script and I would like to remove some specific elements of an array called <code>uniqueWords</code>. The elements I want removed are the following: <code>""</code>, <code>" "</code> and <code>"\n"</code>. To achieve this I tried:</p>
  
  <pre><code>var removeArray = _.remove(uniqueWords, function (word) {return word === '' || word === ' ' || word === '\n'});
  var removeArray2 = _.remove(uniqueWords, function (word) {return _.indexOf(['', ' ', '\n'], word) !== -1});
  
  console.log(removeArray);
  console.log(removeArray2);
  </code></pre>
  
  <p>I am using the js class called loadash, but I got the following results:</p>
  
  <pre><code>["", " ", "↵"]
  
  []
  </code></pre>
  
  <p>My complete code looks like:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  
  &lt;script src="lodash.js"&gt;&lt;/script&gt; 
  
  &lt;body&gt;
  &lt;p id="demo"&gt;&lt;/p&gt;
  
  &lt;textarea cols=150 rows=15 id="texto"&gt;
  "RBD|X|RBD|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTHRa"
  "RBD|X|RBD|C|92173~GJHGX4.NAYE" "SAMBORNSiPOSSSTHRa"
  "RBD|X|RBD|C|92173~GJHGX6.NAYE" "SAMBORNSiPOSSSTHRa"
  "RBD|X|RBD|C|92173~GJHGX8.NAYE" "SAMBORNSiPOSSSTHRa"
  "RBD|X|RBD|C|92173~GJHGXA.NAYE" "SAMBORNSiPOSSSTHRa"
  "RBD|X|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTHRa"
  &lt;/textarea&gt;
  
  &lt;script&gt;
  
  var splitWords = document.getElementById("texto").value.split(/[["\|~]/);
  splitWords = document.getElementById("texto").value.split(/[["\|~]/)
  //document.write(splitWords.toString()); 
  
  uniqueWords = _.uniq(splitWords);
  console.log(uniqueWords);
  var index = uniqueWords.indexOf("");
  var index2 = uniqueWords.indexOf(" ");
  var index3 = uniqueWords.indexOf("\n");
  console.log(index3)
  
  var arrayLength = uniqueWords.length;
  
  
  var removeArray = _.remove(uniqueWords, function (word) {return word === '' || word === ' ' || word === '\n'});
  var removeArray2 = _.remove(uniqueWords, function (word) {return _.indexOf(['', ' ', '\n'], word) !== -1});
  
  console.log(removeArray);
  console.log(removeArray2);
  
  &lt;/script&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>I would like to appreciate any suggestion to achieve this.</p>