title: Convert a javascript list to dictionary
body: <p>I'm trying to convert a javascript list to a dictionary with a specified key. 
  I'm using the following code: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let list = ['cat', 'rabbit', 'fish']
  
  list = list.map(x =&gt; {
    return ({ animal: x });
  })
   
  console.log(list);</code></pre>
  </div>
  </div>
  </p>
  
  <blockquote>
    <p>Of course this doesn't work. 
    Edit: It actually does</p>
  </blockquote>
  
  <p>Expected result:</p>
  
  <pre><code>[
    {
      "animal": "cat"
    },
    {
      "animal": "rabbit"
    },
    {
      "animal": "fish"
    }
  ]
  </code></pre>
  
  <p>Edit:</p>
  
  <p><strong>let</strong> and <strong>list=list</strong> was in fact a typo in the question - it is correct in my real code. I didnt test this snippet as I didnt think it worked. I also then confused myself and did type the expected result wrong. My code is more complex and it didn't make sense to post it all. As works, I think my bug must be elsewhere. Thanks for the help. </p>