title: conditionally return an object-property in javascript
body: <p>So this might look like a weird question but bear with me please:</p>
  
  <p>I have a simple array of strings and I want to map it to an array of objects. pretty simple:
  I would write </p>
  
  <pre><code>arr.map (x =&gt; ({
     header  : x,
     sortType: 'basic'
  }))
  </code></pre>
  
  <p>now, here is the question:
  I would like to check and see if x has a certain value then do not include the sortType at all.
  I would like to do something like</p>
  
  <pre><code> arr.map (x =&gt; ({
         header  : x,
         x==='test' ? (sortType: 'basic') : //don't provide anything
      }))
  </code></pre>
  
  <p>so I would like my final array be something like this:
  <strong><em>And I do not want to have two maps ofcourse!</em></strong></p>
  
  <pre><code>[
  { header: 'Header One' , sortType: 'basic'},
  { header: 'test' },
  { header: 'Another one' , sortType: 'basic'},
  ]
  </code></pre>