写函数实现单词反转功能
this is a word. ==> .word a is this
let strsx = "this is a word.";
function reve(str){
let arr = str.substr(0,str.length-1).split(' ');//分割数组
let result = str[str.length-1] + arr.reverse().join(' ');
console.log(result);//.word a is this
return result;
}
reve(strsx);
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634528.html