标签:
问题:给定英文句子,反转里面的每个单词,例如var reverseWords = function(str) { str = str.trim(); var s = ""; var len = str.length; var w = ""; for(var i = len-1;i>=0;i--){ if(str[i] != " "){ w = str[i] + w; } else{ if(i != 0 && str[i-1] == " ") { continue; } s += w + " " w=""; } } s += w; return s; };
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/lan_liang/article/details/47019509