title: Object Not Maintaining Assigned Values
body: <p>I am looping through an array to create another array of objects in a modified format.</p>
  
  <pre><code>for (i = 1; i &lt;= 37; i++) { // create 37 boxes for days of the month and nearby dates
    room_reservations[i] = {};
    var this_date = getDate();
    var res_count = 0;
    for (var res_index = 0; res_index &lt; reservations.length; res_index++) {
      var this_res = reservations[res_index];
      // bad assignment location
      // res_room = JSON.parse(JSON.stringify(this_res));
      if (this_res.checkin &lt;= this_date &amp;&amp; this_res.checkout &gt; this_date) {
        for (var k = 0; k &lt; this_res.rooms.length; k++) {
          var res_room = {};
          res_room = JSON.parse(JSON.stringify(this_res));
          var this_room = res_room.rooms[k];
          res_room.room_index = k;
          var traveler_count = this_room.travelers.length;
          console.log('traveler_count: ', traveler_count);
          res_room.traveler_count = traveler_count;
          //traveler_counts[i][res_room.room_name] = traveler_count;
          console.log('res_room.traveler_count: ', res_room.traveler_count);
          var room_name = this_room.room_name;
          console.log('room_name: ', room_name);
          res_room.room_name = room_name;
          console.log('res_room: ', res_room);
          room_reservations[i][res_room.room_name] = res_room;
        }
      }
    }
  }
  </code></pre>
  
  <p>Essentially, I console log the object property traveler_count and get the correct value.  But when logging the entire object, the property value is incorrect.  It's like it grabs the value from the next loop.</p>
  
  <p><a href="https://i.stack.imgur.com/ASa71.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ASa71.png" alt="enter image description here"></a></p>
  
  <p>How do I fix this?  It is not just the logging.  The values being set are wrong in the room_reservations array.  For example, I set the attribute name to res_room.room_name and the value to res_room.   But the attribute name does not match the value in the object.</p>
  
  <p><a href="https://i.stack.imgur.com/mB41b.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mB41b.png" alt="enter image description here"></a></p>
  
  <p>Please help.  Thx</p>