title: JavaScript: Dynamically generated object key
body: <pre><code>const cars = [
    {
      'id': 'truck',
      'defaultCategory': 'vehicle'
    }
  ]
  
  const output = []
  
  Object.keys(cars).map((car) =&gt; {
    output.push({
        foo: cars[car].defaultCategory
    })
  })
  
  console.log(output)
  </code></pre>
  
  <p>This work fine, however what I want to achieve is so that the newly crated object has structure of <code>'truck': 'vehicle'</code>.</p>
  
  <p>So if I replace <code>push</code> argument with</p>
  
  <pre><code>${cars[car].id}`: cars[car].defaultCategory
  </code></pre>
  
  <p>I get <code>SyntaxError: Unexpected template string</code></p>
  
  <p>What am I doing wrong?</p>