title: Typescript array map vs filter vs?
body: <p>Here's a typescript method that wants to walk through an array of strings, and return another array of strings, where, strings that match the regexp (formatted something like "[la la la]" will become just "la la la" and strings that don't match are dropped. So that if my input array is: </p>
  
  <pre><code>"[x]", "x", "[y]"
  </code></pre>
  
  <p>it becomes</p>
  
  <pre><code>"x", "y"
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>questions(): string[] {
      var regexp = /\[(.*)\]/;
      return this.rawRecords[0].map((value) =&gt; {
          console.log(value);
          var match = regexp.exec(value);
          if (match) {
              return match[1];
          }
      });
  }
  </code></pre>
  
  <p>I end up with output like this:</p>
  
  <pre><code>"x", undefined, "y"
  </code></pre>
  
  <p>because of the "if (match)". What's the right typescript/javascript way of writing this code?</p>