/** * @param {string}s * @return {string} */ var reverseWords = function (s) { const arr = s.trim().split(/\s+/); const len = arr.length - 1; let res = [];
for (let i = len; i >= 0; i--) { const item = arr[i]; res.push(item); } return res.join(' '); };