title: How to insert particular value based on some matches inside an object
body: <p>I have two objects with the following structure:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>var one = { 
      '26-34-1'  : 100,
      '26-34-84' : 101
  };
  
  var two = [ 
      { 
          from : { id: '34', sid: '26' },
          to   : { id: '1',  sid: '26' } 
      },
      { 
          from : { id: '34', sid: '26' },
          to   : { id: '84', sid: '26' } 
      }
  ];
  </code></pre>
  
  <p>The keys in <code>one</code> <em>(eg. 26-34-1)</em> identify an object in <code>two</code> in the format:<br><code>from.sid</code> - <code>from.id</code> - <code>to.id</code></p>
  
  <p>What I need to do is insert the value from <code>one</code> into <code>two</code> if the <em>key</em> in <code>one</code> matches.  Resulting in:</p>
  
  <pre class="lang-js prettyprint-override"><code>var two = [ 
      { 
          from  : { id: '34', sid: '26' },
          to    : { id: '1',  sid: '26' },
          oneid : { id: 100 }
      },
      { 
          from  : { id: '34', sid: '26' },
          to    : { id: '84', sid: '26' },
          oneid : { id: 101 } 
      }
  ];
  </code></pre>
  
  <p>I can't seem to figure it out, I think it's done with <em>"mapping"</em> but wasn't able to map <code>from.sid</code>, <code>from.id</code> and <code>to.id</code>.  Can someone please shed some light on this?</p>