One line JS solution


  • 0
    D
    var reverseWords = function(str) {
        return str.split(' ').filter(function(e) { return /\S/.test(e)}).reverse().join(' ');
    };
    

Log in to reply
 

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