Here is the problem known as Search and Replace.
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”.
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.
mall should not return
john should return