Javascript solution


  • 0
    C
    var reverseWords = function(str) {
        return str.trim().split(' ').reverse().reduce(function(str, e) {
                if(e === ''){ return str ; } 
                return str + ' ' + e;
            });
    };
    

Log in to reply
 

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