0

I have a problem with handling Object

here is my code

data: {

    '!ref': 'A1:D500',
    A1: { t: 's', v: 'One', z: '@' },
    B1: { t: 's', v: 'Two', z: '@' }, 
    C1: { t: 's', v: 'Three', z: '@' }, 
    D1: { t: 's', v: 'Four', z: '@' }, 
}

for (let i = 2; i <= 40; i += 1) {
    datas.A`${i}` = { t: 's', v: '', z: '@' }
}

I tried like these

datas.['A${i}'] = { t: 's', v: '', z: '@' } datas.A[${i}] = { t: 's', v: '', z: '@' }

result of first try : Line 307:8: Parsing error: Invalid left-hand side in assignment expression. (307:8) result of secone try :nnot set properties of undefined (setting '2')

I want to add A2, A3, A4... and B2, B3, B4... C1,C2,C3..., D1,D2,D3...

what should i do...

zforgo
  • 2,508
  • 2
  • 14
  • 22

0 Answers0