<script>var zi='Isd am a student';var zu=[];var a=0;var b=0;for(var i=0;i<=zi.length;i++){ if(zi[i]==' '||i==zi.length){
zu[b]=''; for(var j=a;j<i;j++){
zu[b]+=zi[j];
}
a=i;
b++;
}else{ continue;
}
}console.log(zu)</script>
1 回答
慕桂英3389331
TA贡献2036条经验 获得超8个赞
var zi='Isd am a student'; String.prototype.mySplit=function(sqrt){ var zu=[]; var a=0; var b=0; for(var i=0;i<=zi.length;i++){ if(zi[i]==sqrt||i==zi.length){ zu[b]=''; for(var j=a;j<i;j++){ zu[b]+=zi[j]; } a=i; b++; }else{ continue; } } return zu; } var arr =zi.mySplit(' '); console.log(arr);
用手机打的代码,有点丑
添加回答
举报
0/150
提交
取消