I'm trying to understand how array works in typescript and I'm struggling to find any solutions on how to replace the index inside an array by a variable, for example with the datas as show below I would like to replace all index numbers by the **part\_id** variable that is inside each index : [![enter image description here](https://i.stack.imgur.com/h12oc.png)](https://i.stack.imgur.com/h12oc.png)

As an example, for the first index, instead of [0] I want to have 26 which is the part\_id etc...

Here's a code samplet ( datas come from an API, I take a copy of the array returned by the API and modify it so that I can do a forEach on them and PatchValue is to set the values onInit)

**Component.ts**

```
 initQuot(){
    this.service.checkExistQuot().subscribe(res => {
      this.quotArray = res;
      this.quotDetails = res.quotation.quotationdetail;
      let group = {};

      this.copy.forEach((val, index)=>
      {
        group[`longueur_${index}`] = '';
        group[`quantity_${index}`] = '';
        group['diameter1'] = '';
        group['diameter2'] = '';

      });
      this.dropForm = this.formBuilder.group(
        group
      );
 this.quotDetails.forEach( (myArray, index) => {
        this.copy.forEach( array1Ttem => {

          this.quotDetails.forEach( array2Item => {

            if(array1Ttem.part_id == array2Item.part_id){
              for (var i = 0; i < this.copy.length; i++) {
                this.copy[myArray.part_id] = this.copy[index];
                console.log(this.copy);
                let patchValue = {};
                this.copy[i].longueur = myArray.longueur; 
                this.copy[i].quantity = myArray.quantity; 
                patchValue[`longueur_${index}`] = this.copy[index].longueur;
                patchValue[`quantity_${index}`] = this.copy[index].quantity;
                this.dropForm.patchValue(patchValue);
              }
            }
            else{
                   console.log("No values matched");
            }

          })
        });
 })
    })
  }

```

If anyone knows a solution/what should I look at the help my issue I would really appreciate it, thank you