Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myReplace(str, before, after) {
- if (before[0] == before[0].toUpperCase()) {
- after = after[0].toUpperCase() + after.slice(1, after.lenght);
- }
- alert(after[0]);
- str = str.replace(before, after);
- return str;
- }
- myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement