![]() ![]() ![]() The String#replace() function has several special character sequences called "replacement patterns". When you use replace(), you don't modify the original string. ![]() Remember JavaScript strings are immutable. "A dollar saved is a penny earned" - only replaces the first // instance by default. const str = 'A penny saved is a penny earned' Make sure you pass a RegExp with the /g flag set as shown below. By default, the String#replace() function in JavaScript only replaces the first instance of a substring.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |