Created
July 1, 2022 20:58
-
-
Save Octagon-simon/ad3dd97a9298949fc2dde36751e8a1fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const search = (search, replace) => { | |
| //the string | |
| const str = "I love to eat banana and mango"; | |
| //replace all occurrences of the searched term | |
| return str.replaceAll( new RegExp(search, 'gi'), replace ); | |
| } | |
| //invoke the function | |
| console.log( search('BANANA', '🍌') ); | |
| console.log( search('MANGO', '🥭') ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment