title: Removing specific keys from an object
body: <p>Given an array of elements like ["a","r","g"] and an object, I am trying to remove the key/value pairs where the keys are elements of the array.</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 shorten(arr, obj) {
    
    var keys = Object.keys(obj);          //make an array of the object's keys
    for(var i = 0; i &lt; arr.length; i++)   //loop for original array (arr) 
        for(var j = 0; j &lt; keys.length; j++)  //loop for "keys" array
            if(arr[i] === obj[keys[j]])           //check for array element matches
                delete obj[keys[j]];                  //delete the matches from object
    return obj;                           //return the new object
      
  }
  
   var arrA = ['a','r', 'g'];
   var oB = {a: 4, u: 1, r: 2, h: 87, g: 4};
   console.log(shorten(arrA,oB))         //I keep getting the original object
                                         //The function isn't shortening things</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>//desired output is:
  
  {u: 1, h: 87}
  </code></pre>
  
  <p>To anyone that reads this and can help me out, thank you in advance.</p>