title: Can't update data variables using functions inside functions
body: <p>Good morning everyone. Here's the problem:</p>
  <p>My goal is to update playerAttackDamage, playerSpeed and playerAccuracy. I created the statChange method mainly for the DRY principle, since there will be many more variables to update, but it doesn't work as intended. The stat gets updated inside the statChange method, but then returns to its original value. If I log the value, I see it updated inside the statChange method, but back to its previous value inside the attackUp function. My guess is the statChange method copies the variable and updates it, instead of updating the original one. Either way, what can I do to update permanently the value? If I do that without using the statChange method, it works perfectly, but as I said, the code would become much longer and repetitive. Any help is deeply appreciated. Here's the code:</p>
  <p>Have a good day, y'all!</p>
  <pre><code>    el: '#app',
      data: {
          playerAccuracy: 50,
          playerAttackDamage: 0,
          playerSpeed: 0,
          monsterSpeed: 2
          turns: []
      },
      methods: {
  
          checkTurnOrder: function(action) {
              if (this.playerSpeed &gt; this.monsterSpeed) {
                  action();
                  setTimeout(() =&gt; {
                      this.monsterTurn();
                  }, 1000);
                  
              } else {
                  this.monsterTurn();
                  setTimeout(() =&gt; {
                      action();
                  }, 1000);
              }
          },
  
          statChange: function(stat, change, statName) {
              stat += change;
              this.turns.unshift({
                  isPlayer: true,
                  text: this.capitalize(statName) + ' stat raised by ' + change + '. Current ' + statName + ': ' + stat
              })
          },
  
          attackUp: function() {
              var yourTurn = () =&gt; {
                  this.statChange(this.playerAttackDamage, 2, 'attack')
              }
              this.checkTurnOrder(yourTurn);
  
          },
  
          speedUp: function() {
              var yourTurn = () =&gt; {
                  this.statChange(this.playerSpeed, 2, 'speed')
              }
              this.checkTurnOrder(yourTurn);
          },
  
          accUp: function() {
              var yourTurn = () =&gt; {
                  this.statChange(this.playerAccuracy, 10, 'accuracy')
          }
          this.checkTurnOrder(yourTurn);
          },
      },
  });```
  </code></pre>