silver-hands / sss

0 stars 0 forks source link

【Q080】151. 翻转字符串里的单词 #80

Open fly0o0 opened 4 years ago

fly0o0 commented 4 years ago

151. 翻转字符串里的单词

fly0o0 commented 4 years ago
/**
 * @param {string} s
 * @return {string}
 */
var reverseWords = function(s) {
  s = s.trim()

  s = s.split(/\s+/)

  s = s.reverse()

  return s.join(' ')
};