70168162

Date: 2021-11-30 11:02:56
Score: 4.5
Natty:
Report link

Personally I would use map and store each variable on an object, like so:

const sums = { [key: string]: <insert type of each Table2 item> }

if (this.storedData?.Table2?.length)
    {
      this.storedData.Table2.map((tableItem, index) => 
        sums[`sum${index || ''}`] = tableItem
      )
      
      if(sums.sum.DataId = '4')
      {
        //do logic here
      }
...

This will build a dynamic dictionary of objects for you, but I'm not sure what you want wanting to do with the if statement and the do logic here parts of the code. Could you elaborate your requirements a bit there please?

Reasons:
  • RegEx Blacklisted phrase (3): Could you elaborate your
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: Robert Dempsey