I am trying to dynamically use the previous property's value for calculation of next property. I have a function like this in Typescript:
MacroGenerator(calories) {
  this.caloriedata['macroarray'] = [
    { 
      name: 'Low Carb, High Fat',
      pmacro: (Math.round(calories*220.46226218100)/100),
      pcals: (4*this.caloriedata['macroarray'][0].pmacro), // THIS IS HOW I TRIED ACCESSING THE PROPERTY AND GETTING ERROR
      fcals: (calories*0.3),
      fmacro: (Math.round(this.caloriedata['macroarray'][0].fcals/9)/100),
      ccals: (calories-this.caloriedata['macroarray'][0].pcals-this.caloriedata['macroarray'][0].fcals),
      cmacro: (Math.round(this.caloriedata['macroarray'][0].ccals/4)/100),
    }
  ]
}
I suppose the object isn't instantiated as of when I am trying to access. Is there any way to access it?
 
    