0

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.

2
  • 1
    just use map and then another map. Commented Dec 20, 2021 at 10:30
  • Just loop over the array and the get the object whose value you want to change and then change it. Simple Commented Dec 20, 2021 at 10:30

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.