I need help . My code is not passing two test and I really do not know how to make it pass this tests
my code so far
function myReplace(str, before, after) {
let capital = after[0].toUpperCase();
let upperletter =after.replace(after[0],capital);
return str.replace(before, upperletter);
}
myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
The Test it's not passing :
myReplace("Let us go to the store", "store", "mall") should return "Let us go to the mall".
myReplace("This has a spellngi error", "spellngi", "spelling") should return "This has a spelling error".
You need to take account for test cases that don’t need to be uppercased. If before parameter is not capitalized, you shouldn’t replace with capitalized word.
Also, please format your code next time so it’s easier to view the code. You can choose preformatted text option when you are pasting the code.
okay . yeah sorry about that thanks I will