mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-19 21:09:51 +08:00
fix(curriculum): add missing content replaceAll() in JS strings review (#63895)
This commit is contained in:
parent
e0d21f30c9
commit
0029c51a9a
@ -104,6 +104,13 @@ console.log(text.toLowerCase()); // "hello, world!"
|
||||
const text = "I like cats";
|
||||
console.log(text.replace("cats", "dogs")); // "I like dogs"
|
||||
```
|
||||
|
||||
- **The `replaceAll()` Method**: This method allows you to find all occurrences of a specified value (a word, character, or pattern) in a string and replace them with another value. It works like replace(), but instead of stopping after the first match, it updates every match found in the string.
|
||||
|
||||
```js
|
||||
const text = "I love cats and cats are so much fun!";
|
||||
console.log(text.replaceAll("cats", "dogs")); // "I love dogs and dogs are so much fun!"
|
||||
```
|
||||
|
||||
- **The `repeat()` Method**: This method is used to repeat a string a specified number of times.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user