Closest array element

Why is this not working? I am trying to find the closest child.

    public GameObject test;
	public Transform[] nodes;

	public GameObject closest;

	
	// Update is called once per frame
	void Update () {
		nodes = test.GetComponentsInChildren<Transform>();
		nodes [0] = nodes [nodes.Length - 1];


		float dist = Vector3.Distance (transform.position, nodes[0].position);

		for(int i=0;i<nodes.Length;i++){
			float curDist = Vector3.Distance(transform.position, nodes*.position);*
  •  	if(curDist < dist){*
    

_ closest = nodes*.gameObject;_
_
}_
_
}_
_
}*_

You need to update ‘dist’ as well as ‘closest’:

       if(curDist < dist){
             closest = nodes*.gameObject;*

dist = curdist;
}
As the for loop can start at 1 rather than 0.