Festina
Festina

Reputation: 325

How to change data in the object with array of objects in JS

I have an object and need to change phone in Sidney into '1111', and in NY into '2222'. How can I do it?

      data = {
          order: 1,
          name: 'John',
          address: [
            {
              order: 1,
              name: 'Sidney',
              phone: '000',
            },
            {
              order: 2,
              name: 'NY',
              phone: '000',
            }, ], }

I tried to use map as **data.address.map((item) => )** but do not know how to change both variant simultaneously and add to data.

Upvotes: 0

Views: 32

Answers (0)

Related Questions