Javascript solution


  • 0
    T
    var reverseString = function(s) {
        answer = ''
        for (i = s.length - 1; i >= 0; i--) {
            answer = answer.concat(s[i])
        }
        return answer
    };
    

    String.split('') will cause a runtime error if called within the for loop.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.