title: How to create a function that assigns property values to other other properties?
body: <p>I would like to have a <code>function</code> that can loop through specific child <code>properties</code> of a <code>variable</code> and assign those <code>variables</code> to another <code>variable</code> with the same structure.</p>
  
  <p>Assigning the current values to a new <code>variable</code> is useful if the original <code>variable</code>'s <code>properties</code> will change values often.</p>
  
  <p>I can't seem to think of the correct logic for looping through specific <code>properties</code> only. The goal is to prevent assigning individual <code>properties</code> line by line, in a case like</p>
  
  <pre><code>objToLookAt.firstProperty.a = objToLookAtCopy.firstProperty.a;
  </code></pre>
  
  <p>Here's the JavaScript with the structure:</p>
  
  <pre><code>var objToLookAt = {
      firstProperty: {
          a: 84, b: 66, c: 37, d: 20
      },
      secondProperty: {
          a: 79, b: 26, c: 55, d: 84
      }, 
      skipThirdProperty: {
          a: 79, b: 26, c: 55, d: 84
      },  
      skipFourthProperty: {
          a: 79, b: 26, c: 55, d: 84
      }   
  };
  
  var objToLookAtCopy = {
      firstProperty: {
          a: null, b: null, c: null, d: null
      },
      secondProperty: {
          a: null, b: null, c: null, d: null
      }    
  };
  
  function AssignObjValues(objWithValues, objToAssignValuesTo){
      //loop code goes here
      //for each property inside objToLookAt, assign every child of firstProperty and secondProperty
      //to = objToLookAtCopy child properties  
  
      console.debug(objToAssignValuesTo); //display only the first two properties in console
  }
  
  AssignObjValues(objToLookAt, objToLookAtCopy);
  </code></pre>