Search and Replace
Perform a search and replace on the sentence using the arguments provided and return the new sentence.
First argument is the sentence to perform the search and replace on.
Second argument is the word that you will be replacing (before).
Third argument is what you will be replacing the second argument with (after).
Note: 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
Tests
- Waiting: 1.
myReplace("Let us go to the store", "store", "mall")
should return the stringLet us go to the mall
. - Waiting: 2.
myReplace("He is Sleeping on the couch", "Sleeping", "sitting")
should return the stringHe is Sitting on the couch
. - Waiting: 3.
myReplace("I think we should look up there", "up", "Down")
should return the stringI think we should look down there
. - Waiting: 4.
myReplace("This has a spellngi error", "spellngi", "spelling")
should return the stringThis has a spelling error
. - Waiting: 5.
myReplace("His name is Tom", "Tom", "john")
should return the stringHis name is John
. - Waiting: 6.
myReplace("Let us get back to more Coding", "Coding", "algorithms")
should return the stringLet us get back to more Algorithms
.
/** * Your test output will go here */