change the position of object in array inside other object

in given data every ingredient have its substitute option while I can
select any substitute option for example if I want to change masala
with its substitute output will change the position of substitute with
it’s option and output should be given below

i want to replace masala with normal masala

  • i have to create a function who replace ingredient with it’s substitute and interchange the position of both *

input

const oData = [
    { CurryName: 'Chiken', id: 0 },
    {
      ingredients: [
        {
          id: 1,
          name: 'onion',
          property: { color: 'yellow', Quantity: 'half KG', price: 120 },
          subOption: [
            {
              id: 11,
              name: 'redOnion',
              property: { color: 'red', Quantity: '1 KG', price: 120 },
            },
            {
              id: 12,
              name: 'whiteOnion',
              property: { color: 'white', Quantity: '2 KG', price: 120 },
            },
          ],
        },
        {
          id: 2,
          name: 'oil',
          property: { color: 'green', Quantity: 'half LT', price: 120 },
          subOption: [
            {
              id: 21,
              name: 'yellowOil',
              property: { color: 'yellow', Quantity: '1 LT', price: 120 },
            },
            {
              id: 22,
              name: 'olivoOil',
              property: { color: 'golden', Quantity: '2 LT', price: 120 },
            },
            {
              id: 22,
              name: 'CastrolOil',
              property: { color: 'silk', Quantity: '2 LT', price: 170 },
            },
          ],
        },
        {
          id: 3,
          name: 'masala',
          property: { color: 'gray', Quantity: '1Tspoon', price: 30 },
          subOption: [
            {
              id: 31,
              name: 'garamMasala',
              property: { color: 'Garam', Quantity: '2Tspoon', price: 30 },
            },
            {
              id: 32,
              name: 'chikenMasala',
              property: { color: 'green', Quantity: ' 3Tspoon', price: 30 },
            },
            {
              id: 33,
              name: 'normalMasala',
              property: { color: 'red', Quantity: '5Tspoon', price: 30 },
            },
          ],
        },
      ],
    },
  ];
  
  // in given data every ingredient have it's substitute option while i can select any supstitute option for example if i  want to change masala with its substitute output will change the position of substitue with it's option and output should be given below
  //i want to replace masala with normal masala
  const output = [
    { CurryName: 'Chiken', id: 0 },
    {
      ingredients: [
        {
          id: 1,
          name: 'onion',
          property: { color: 'yellow', Quantity: 'half KG', price: 120 },
          subOption: [
            {
              id: 11,
              name: 'redOnion',
              property: { color: 'red', Quantity: '1 KG', price: 120 },
            },
            {
              id: 12,
              name: 'whiteOnion',
              property: { color: 'white', Quantity: '2 KG', price: 120 },
            },
          ],
        },
        {
          id: 2,
          name: 'oil',
          property: { color: 'green', Quantity: 'half LT', price: 120 },
          subOption: [
            {
              id: 21,
              name: 'yellowOil',
              property: { color: 'yellow', Quantity: '1 LT', price: 120 },
            },
            {
              id: 22,
              name: 'olivoOil',
              property: { color: 'golden', Quantity: '2 LT', price: 120 },
            },
            {
              id: 22,
              name: 'CastrolOil',
              property: { color: 'silk', Quantity: '2 LT', price: 170 },
            },
          ],
        },
        {
         
              id: 33,
              name: 'normalMasala',
              property: { color: 'red', Quantity: '5Tspoon', price: 30 },
           
         
          subOption: [
            {
              id: 31,
              name: 'garamMasala',
              property: { color: 'Garam', Quantity: '2Tspoon', price: 30 },
            },
            {
              id: 32,
              name: 'chikenMasala',
              property: { color: 'green', Quantity: ' 3Tspoon', price: 30 },
            },
            {
              id: 3,
              name: 'masala',
              property: { color: 'gray', Quantity: '1Tspoon', price: 30 },
             }
          ],
        },
      ],
    },
  ];
  
  console.log(output)