Vector3.distance or (a-b).sqrMagnitude not working properly

Your code even compile. (btw, please use the code tags Using code tags properly )

you can’t call “foods.transform.position”, foods is an array, you probably want “foods*.blah…” i being the loop iterator.*
why are you using doubles and not floats?
why are you comparing “a” against “99999999999.00000000000000000”, and why all the decimal places?
are you sure both objects are in the “foods” array?