Trying to achevie Shorter code less repetition

this is the code iam using but cant figure out a way to make it short

public var health = 200;

function OnTriggerEnter(other:Collider){

var ammorPls: GameObject[] = GameObject.FindGameObjectsWithTag("ammor");
    
// Assign the builtin array to a js Array
   var ammorPlsB = new Array (ammorPls);

	if(other.tag=="bullet"){
		health = health-10;
	}
    
   	if(health<10) {
        //remove ammor sections from range
   
           for (var a = 0; a < 3; a++) {
   		
              ammorPlsB[a].rigidbody.isKinematic=false;
              ammorPlsB[a].rigidbody.useGravity=true;
              ammorPlsB[a].transform.parent = null;
              ammorPlsB[a].collider.enabled=true;
          
              }
   	  }
   	     

   	if(health<20) {
        //remove ammor sections from range
   
           for (var b = 3; a < 6; a++) {
   		
              ammorPlsB**.rigidbody.isKinematic=false;**

ammorPlsB**.rigidbody.useGravity=true;**
ammorPlsB**.transform.parent = null;**
ammorPlsB**.collider.enabled=true;**

}
** }**

I would do something like:

static function DropObject(obj : GameObject)
{
    obj.rigidbody.isKinematic = false;
    obj.rigidbody.useGravity = true;
    obj.transform.parent = null;
    obj.collider.enabled = true;
}

function OnTriggerEnter(other:Collider)
{
    var ammorPls: GameObject[] = GameObject.FindGameObjectsWithTag("ammor");
    var ammorPlsB = new Array (ammorPls);
    
    if(other.tag=="bullet")
    {
        health = health-10;
        var index : int = health / 10;
        index = Mathf.Clamp(index*3, 0, ammorPlsB.length-2);
        for (var a = 0; a < 3; a++) {
            DropObject(ammorPlsB[index + a])
        }
    }
}