| 2018.8.29 | javascript |
function replaceChat(source,pos,newChar){
if(pos<0||pos>=source.length||source.length==0){
return "invalid parameters...";
}
var iBeginPos= 0, iEndPos=source.length;
var sFrontPart=source.substr(iBeginPos,pos);
var sTailPart=source.substr(pos+1,source.length);
var sRet=sFrontPart+newChar+sTailPart;
return sRet;
}
alert(replaceChat("happy",1,"b"));
更新列表:
*
参考文章:
[2]: