In the NearestSpawnpoint(...) method, we set nearestSpawnpoint to the first (array index 0) GameObject in the array as our default. We then looped through the rest of the array (array index 1 up to spawnPoints.Length). For each GameObject in the array, we checked the distance from the current spawnpoint position (Vector3 spawnPointPos) to the provided Vector3 source parameter position is less than the shortest distance so far, and if it is, we updated the shortest distance, and also set nearestSpawnpoint to the current element. Once we'd searched the arrray, we returned the GameObject that the nearestSpawnpoint variable refers to.
Note that to keep the code simple, we are not performing a test for the NearestSpawnpoint(...) method – production code would require that a test be made in case the received parameter was null, in which case the code would exit the method without taking any action.