title: Problem updating object properties inside a promise-aware for loop in javascript
body: <p>I am having a problem accessing updated object properties inside a for loop in Javascript. </p>
  
  <pre><code>let distribution = await ctx.db.query.distribution(
        {
          where: {
            id,
          },
        },
        `
      {
        id
        clients {
          id
          wallet {
            amount
          }
        }
      }`,
    );
  
  let count = 0;
  
  for (const client of distribution.clients) {
     await ctx.db.mutation.updateWallet({
         where: {
           id: client.id,
         },
         data: {
           amount: client.wallet.amount + someAmount,
         },
      });
      distribution.clients[count].wallet.amount = client.wallet.amount + someAmount;
      count++;
    }
  </code></pre>
  
  <p>In the above code, I execute a graphQL query to fetch all information associated with a distribution. I then want to iterate through the associated clients array and update each client’s wallet. The same client may appear multiple times in this array and each time 
  their wallet must be updated.</p>
  
  <p>A problem occurs when a wallet has already been updated in a previous iteration. When I try to update the amount a second time, the client.wallet.amount reflects the initial value of the wallet rather than value after the first update. </p>
  
  <p>Clearly the property clients[count].wallet.amount attribute of the distribution object isn’t being updated after each iteration. I thought javascript objects were passed by reference, and therefore the object should be updated after each iteration. </p>
  
  <p>Could someone explain to me why the distribution object property is not being updated and how I can update it correctly?</p>
  
  <p>FYI: I cannot use other loops such as forEach as it is not promise-aware and does not suppose async/await</p>