Search and Replace Algorithm

Hello im trying to solve the upper case section of the algorithm in search and replace, but im not figuring it out in my way of solving it! My solution works with other examples but not with uppercase ones!algorithm

Here is my code! If you can give me a tip it would be helpful! :slight_smile:

After you’ve found the word to replace, check first if the first letter is uppercase. If so, you should also uppercase the first letter of the replacement word.

You may want to check out .charCodeAt() or regex to test if a letter is uppercase.

EDIT. Please copy and paste your code in the future instead of posting a screenshot, so others can copy and paste your code as well (instead of typing everything).

1 Like