写函数实现单词反转功能

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);

 

posted @ 2020-08-18 17:01  JackieDYH  阅读(2)  评论(0编辑  收藏  举报  来源