How to draw line between array's gameobjects

Hello my friends,
I’ve been searching all over unsuccesfuly for an answer: I have an array of gameobjects, and I want a line (doesnt matter if is a gizmo or a debug.drawline) going from one object to another to another. Any advice?
Thank you,
P.

function Update() {
for (var i = 1; i < array.Length; i++) {
Debug.DrawLine(array[i-1].transform.position, array*.transform.position);*

  • }*
    }
    Change ‘array’ to whatever you’ve named your game object array.

Thank you Robertu,
this might work on javascript but not in C# as position is treated like a method not like a variable. I can´t figure how to add this drawline into my code:

public GameObject checkpoints;

public GameObject NextCheckpoint (GameObject current) {
	
	if (checkpoints.Length < 1)
		print ("ERROR - no checkpoints have been detected to array!");
	
	int arraySize = checkpoints.Length;
			
	int nextIndex = 0;
				
	int currentIndex = -1;
	
	
	
	
	
	for (int i =0; i < checkpoints.Length; i++){
				
		if (current == checkpoints*)*
  •   		currentIndex = i;*
    
  •   }*
    
  •   int lastIndex = (checkpoints.Length - 1);*
    
  •   if (currentIndex > -1 && currentIndex < lastIndex)*
    
  •   	nextIndex = currentIndex + 1;*
    
  •   return checkpoints [nextIndex];*
    
  • }*

}

Sorry, it works!