JavaScript Solution


  • 3
    F
    /**
     * @param {string} s
     * @return {string}
     */
    var reverseString = function(s) {
        return s.split('').reverse().join('');
    };
    

  • 0
    M

    functional answer:

    /**
     * @param {string} s
     * @return {string}
     */
    const reverseString = s => s ? s.split('').reduce((acc,curr) => curr+acc) : '';
    

Log in to reply
 

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