0

So, I have

{
  'A': {
    'B': 1
  },
  'B': {
    'A': 1
  }
}

And now I need to add more keys into 'B' so it would output

{
  'A': {
    'B': 1
  },
  'B': {
    'A': 1,
    'C': 2,
    'D': 4
  }
}

The final result needs to be a similar object and not an array. Obviously .push(), .splice, etc, does not work.

How do I do this?

mignz
  • 3,648
  • 2
  • 20
  • 21

1 Answers1

0

If A/B/C is coming from the variables then, a[var1][var2]=var3; in that way you have to design a logic , just to keep you objects according to your requirements.

Kartikeya Sharma
  • 553
  • 1
  • 5
  • 22