title: Using two separate objects, I would like to return an object with the matching key, value pairs?
body: <p>I have created three <code>functions</code>, that can make two separate <code>arrays</code> with the matching <code>keys</code> and the matching <code>properties</code>. I would like to use those two <code>arrays</code> to create a new <code>object</code> with all of the matching pairs. Below I included the <code>functions</code> I have so far.</p>
  
  <p>I am a beginner in <code>Javascript</code> ( which is most likely already apparent) so if you can explain each step thoroughly and not get to complex I would greatly appreciate it.</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>function contains(array, obj_to_check){
   for(var i = 0; i &lt; array.length; i ++) {
    if (array[i] == obj_to_check) {
     return true;
    }
   } 
  }
  function sharedKeys(obj1, obj2) {
   var obj1Keys = Object.keys(obj1);
   var obj2Keys = Object.keys(obj2);
   var sharedArray = [];
   for( var x = 0; x &lt; obj1Keys.length; x++){
    if (contains(obj2Keys, obj1Keys[x])){
    sharedArray.push(obj1Keys[x]);
    }
   }
   return sharedArray;
  }
  function sharedProperties(obj1, obj2) {
   var obj1Props = [];
   var obj2Props = [];
   var propertiesArray = [];
   for(var i in obj1)
    obj1Props.push(obj1[i]);
   for(var x in obj2)
    obj2Props.push(obj2[x]);
   for (var y = 0; y &lt; obj1Props.length; y ++){
    if(contains(obj1Props, obj2Props[y])){
     propertiesArray.push(obj2Props[y])
    }
   }
   return propertiesArray;
  }</code></pre>
  </div>
  </div>
  </p>