Array give return reverse string?why undefined?

Your loop will run i-- if i >= 0. So if its equal to zero it will remove one, meaning it will try and take from index -1 which is outside the array, resulting in undefined.

If you ran this in lets say C# the program would crash with an IndexOutOfBounds exception.