标签:组合 glob function and cas turn 链接 合并 before
1.要求
2.思路
3.代码
function myReplace(str, before, after) {
str = str.split(" ");
if(before[0]>=‘A‘&&before[0]<=‘Z‘){
after = after.slice(0,1).toUpperCase()+after.slice(1);
}
var num = str.indexOf(before);
str.splice(num,1,after);
return str.join(" ");
}
myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
4.相关链接
Search and Replace -freecodecamp算法题目
标签:组合 glob function and cas turn 链接 合并 before
原文地址:https://www.cnblogs.com/ahswch/p/9298281.html