code: function nestedArrayRename ($nestedArray) {
      // start number rows at zero
      var rowNum = 0
      // go through each array item and make sure row number is correct
      $nestedArray.find('.nested-array-item').each(function () {
          var $item = $(this)
          // build index string
          var rowIndex = '['+rowNum+']'
          // rename any input elements
          $item.find('input,select').each(function () {
              var $input = $(this)
              // get name
              var name = $input.attr('name')
              // replace index
              name = name.replace(indexRegExp, rowIndex)
              // set new name
              $input.attr('name', name)
              // get id
              var id = $input.attr('id')
              // replace index
              id = id.replace(idRegExp, rowNum)
              // set updated id
              $input.attr('id', id)
              // trigger change event on input
              $input[0].dispatchEvent(new Event('change', {
                  bubbles: true,
                  cancelable: true,
              }))
          })
          // set new row number for next row
          rowNum++
      })
  }
docs: @function nestedArrayRename
  
  go through nested array input elements and set correct index for name