Problem storing instantiated objects to an array

Hi guys, I’m trying to Instantiate a set of objects whenever a Space is pressed and store them into currentObj array so I can access them later. But I keep getting problem where the rest of currentObj array are null except for the last index.
Here is my code:

    public GameObject[] obj;
	public GameObject spawnObj;
	public GameObject[] currentObj;
	Vector3 spawnPoint;
	void Start(){
		spawnPoint = transform.position;
		}

	void Update(){
		if (Input.GetKeyDown (KeyCode.Space)) {
						for (int i = 0; i< 10; i++) {
								currentObj = new GameObject[10];
								spawnObj = (GameObject)Instantiate (obj [(int)Random.Range (0, obj.Length)], spawnPoint, Quaternion.identity) as GameObject;
								currentObj *= spawnObj.gameObject;*
  •  						Debug.Log(i);*
    
  •  						spawnPoint.x = spawnPoint.x + 1.2f;*
    
  •  				}*
    
  •  		}*
    

}
}
Any help on this would be greatly appreciated! Thank you.

This line:

currentObj = new GameObject[10];

Needs to be moved outside of the for loop.

Code inside the loop will be executed multiple times. If you create the array inside the loop, you’ll recreate the array once per loop pass.

You want one array. Code that executes exactly once usually isn’t in a loop.

What you need to be doing is instead of

currentObj = new GameObject[10];

you should initialize the array once, instead of in every iteration in the for loop.
Like so:

GameObject currentObj = new GameObject[10];