String Replace in JavaScript
Level 265 keystrokes
replace() returns a new string with the first match of a pattern replaced.
JavaScript code
// Create a string1let str = "Hello World";// replace() searches for "World" and replaces it with "JS"// Returns a new string; original is unchanged// Result: "Hello JS"2console.log(str.replace("World", "JS"));Output
Hello JS
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this JavaScript code and how often they appear.
"× 6;× 2.× 2(× 2)× 2,× 1=× 1