Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

How to Use the replace() String Method in javascript

// use a regex in place of a string as a replacer
const string = "Hello world"

const modified = string.replace(/o/g, "--")

console.log(string)
// Hello world

console.log(modified)
// Hell-- w--rld
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #How #Use #String #Method #javascript
ADD COMMENT
Topic
Name
4+8 =