title: Push to an array from with in a computed property in Vue.js 2
body: <p>I am looking to push to an array from with in a computed property in Vue.js 2, Vue is being used within Laravel and I am getting the following response.</p>
  
  <blockquote>
    <p>createSelection:"(error during evaluation)"</p>
  </blockquote>
  
  <p>The following code is being used:</p>
  
  <pre><code>&lt;template&gt;
    &lt;div&gt;
      &lt;div&gt;Credits carried through: {{ credits }}&lt;/div&gt;
      &lt;div v-for="meal in meals"&gt;
        {{meal}}
        &lt;input :id="meal" :name="meal" v-model.number="creditsPerMeal[meal]" type="number"&gt;
      &lt;/div&gt;
      &lt;div&gt;
        Credits used: {{creditsSum}}/{{credits}}
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
    export default {
  
      mounted() {
          console.log('Component ready.');
  
          console.log(JSON.parse(this.f));
  
      },
  
      props: ['f','c'],
  
      name: 'credits',
      data: function () {
       var meals = JSON.parse(this.f)
  
       var creditsPerMeal = {}
       for (var i = 0; i &lt; meals.length; i++) {
         creditsPerMeal[meals[i]] = 0
       }
  
       var createSelection = []
  
  
        return {
          credits: this.c,
          meals,
          creditsPerMeal
        }
      },
  
      computed: {
        creditsSum () {
          return Object.values(this.creditsPerMeal).reduce((a, b) =&gt; a + b, 0)
        },
  
        createSelection: function (){
          for (var i = 0; i &lt; meals.length; i++) {
             createSelection.push({
                food: meals[i],
                quantity: creditsPerMeal[meals[i]]
              })
            }
        }
      }
    }
  &lt;/script&gt;
  </code></pre>