comparing variables of gameobjects in an array

Hello, I have an array with two game objects in it and I want to compare their int variables “ATK” and see which one is bigger (and then destroy the game object that has the smaller). The problem is that the specific game objects that make up the array change throughout the game so I want to call the ATK variable just using the index of the array and I don’t know how to access a game object’s variables in an array like that

I don’t know if I managed to ask my question clearly but any help would be appreciated!

float highestAtk = 0;
GameObject toDestroy;
for(int i = 0; i < whateveryourarrayis.Length; i++) {
if(whateveryourarrayis*.GetComponent().atk > highestAtk) {*
toDestroy = whateveryourarrayis*;*
highestAtk = whateveryourarrayis*.GetComponent.atk;*
}
}

Destroy(toDestroy);

Exactly as DoubleIsLoveDoubleIsLife, “whatcomponenttheattackvariableisin”, meaning the only GameObject variables that exist are Here or the ones you create.