Intuitive Javascript Solution


  • 0
    D
    var reverseWords = function(s) {
        // reverse string word by word
        return s.split(' ').reduce((reversed, curr) => {
            reversed.push(curr.split('').reverse().join(''))
            return reversed;
        }, []).join(' ');
    };
    

Log in to reply
 

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