With a while loop:

With A While Loop

We can cut down on the number of operations by recognizing that we don't need to do len(str)-1 iterations. Instead of using just one pointer that simply iterates through the string from its end, why not use two?

JAVASCRIPT
OUTPUT
Results will appear here.