Created
December 5, 2020 15:56
-
-
Save smpnjn/4d8308ff82ec273293352a9480fa47cd to your computer and use it in GitHub Desktop.
This file contains 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
let string = 'orange apple apple apple pen'; | |
// You need regex to replace all instances of something with replace() | |
let newString1 = string.replace('apple', 'kiwi'); // returns 'orange kiwi apple apple pen' | |
// But this is not the case with replaceAll | |
let newString2 = string.replaceAll('apple', 'kiwi'); // returns 'orange kiwi kiwi kiwi pen' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment