title: How to set array key as it's index in javascript/node js
body: <p>I have an array of objects like this :</p>
  
  <pre><code>var kvArray = [ 
     { 
         number: '123',
         duration: '00:00:00' 
     },
     { 
        number: '324',
        duration: '00:00:00' 
     }]
  </code></pre>
  
  <p>I want to generate a new array from the above array such that the <code>number</code> key becomes the index.</p>
  
  <p>This is what I tried</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>var kvArray = [
     { 
         number: '123',
         duration: '00:00:00' 
     },
     { 
         number: '324',
         duration: '00:00:00' 
     }]
  
  var reformattedArray = kvArray.map(obj =&gt;{ 
     var rObj = {};
     rObj[obj.number] = obj.duration;
     return rObj;
  });
  console.log(reformattedArray)</code></pre>
  </div>
  </div>
  </p>
  
  <p>The above output looks like this in the console with 0 and 1 as the index:
  <a href="https://i.stack.imgur.com/eHSrO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eHSrO.png" alt="enter image description here"></a></p>
  
  <p>Instead I want the output array to be like this :</p>
  
  <pre><code>123: {"00:00:00"}
  324: {"00:00:00"}
  </code></pre>
  
  <p>such that instead of 0 , 1 as the index I have 123 and 324 as the index.
  So that if write test_array[123] in my code I should be able to get 00:00:00 in the output. Is it possible to achieve what I'm trying to do here?
  Suggest better ways how this can be done</p>
  
  <p>How do I do this?</p>