实现单词之间的反转
// 考虑标点符号的情况
var str = "this is a word."
var arr = str.substr(0, str.length - 1).split(" ");
var result = str[str.length - 1] + arr.reverse().join(" ");
console.log(result) //.word a is this
// 不考虑标点符号的情况
var str1 = "this is a word"
var arr1 = str1.split(" ");
var result1 = arr1.reverse().join(" ");
console.log(result1) //word a is this