/**
* @param {string} s
* @return {string}
*/
var reverseWords = function(s) {
let arr1=s.split(' ').filter(function(val){
return val;
});
let s1='';
for(let i=0;i<arr1.length;i++){
let word=(i==arr1.length-1)?arr1[0]:(arr1[arr1.length-i-1]+' ');
s1=(s1+word);
}
return s1;
};
用到数组方法split filter 三元运算符