title: How can I only keep items of an array that match a certain condition?
body: <p>I have an array, and I want to filter it to only include items which match a certain condition. Can this be done in JavaScript?</p>
  
  <p>Some examples:</p>
  
  <pre><code>[1, 2, 3, 4, 5, 6, 7, 8] // I only want [2, 4, 6, 8], i.e. the even numbers
  
  ["This", "is", "an", "array", "with", "several", "strings", "making", "up", "a", "sentence."] // I only want words with 2 or fewer letters: ["is", "an", "up", "a"]
  
  [true, false, 4, 0, "abc", "", "0"] // Only keep truthy values: [true, 4, "abc", "0"]
  </code></pre>