Here is the problem known as Search and Replace.
It’s saying,
Preserve the case of the first character in the original word when you are replacing it. For example if you mean to replace the word “Book” with the word “dog”, it should be replaced as “Dog”.
But in test case there is,
myReplace("Let us go to the store", "store", "mall")
should return “Let us go to the mall”.
and also,
myReplace("His name is Tom", "Tom", "john")
should return “His name is John”.
I wrote code to change all after
values from myReplace
function to capitalize.
Why mall
should not return Mall
but, john
should return John
?