title: JavaScript - Looping and adding a key value pair to JSON object
body: <p>I'm attempting to sort through 'response', a JSON object passed through the function from an API, and insert a key 'img:' and a value, the image src, based on the planet's name.</p>
  
  <p><strong>What I have tried:</strong>
  I tried using response.push as found in a few StackOverflow links, but that just adds the key value to the entire object as a separate value. I also tried response[i], but that doesn't seem to be valid since my console gives me an error.</p>
  
  <p><strong>A Few of the Links I've Visited</strong> These are helpful, but don't seem to address the looping sequence I'm after.</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/14272051/appending-a-key-value-pair-to-a-json-object">Appending a key value pair to a json object</a></li>
  <li><a href="https://stackoverflow.com/questions/1168807/how-can-i-add-a-key-value-pair-to-a-javascript-object-literal">How can I add a key/value pair to a JavaScript object?</a></li>
  <li><a href="https://stackoverflow.com/questions/5296697/js-json-pair-key-value">JS JSON Pair Key &amp; Value</a></li>
  </ul>
  
  <p>I would appreciate any help or guidance.</p>
  
  <pre><code>  app.controller('mainCtrl', function($scope, parseService) {
  
    $scope.getParseData = function() {
      parseService.getPlanet().then(function(response) {
  
        for(var i = 0; i &lt; response.length; i++)
          if (response[i].name === "Hoth") {
            console.log("We found hoth!");
            response.push({'img': 'testpic.jpg'}); //Trouble w. this line
          } else {
            console.log("not Hoth");
          }
          $scope.planets = response;
  
      });
    }
    $scope.getParseData();
  
  });
  </code></pre>