Skip to content

Commit 1cca628

Browse files
NiloySaha84huyenltnguyenmajestic-owl448
authored
fix(curriculum): clarify that replace() returns a new string in JS lesson (freeCodeCamp#61730)
Co-authored-by: Huyen Nguyen <[email protected]> Co-authored-by: Ilenia M <[email protected]>
1 parent 7c25ffc commit 1cca628

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

curriculum/challenges/english/25-front-end-development/lecture-working-with-string-modification-methods/67326c29dcd98fc5ecc49779.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ In JavaScript, there are many scenarios where you may need to replace a portion
1111

1212
For instance, you might need to update user information in a URL, change the formatting of dates, or correct errors in user-generated content.
1313

14-
The `replace()` method in JavaScript allows you to find a specified value (like a word or character) in a string and replace it with another value.
14+
The `replace()` method in JavaScript allows you to find a specified value (like a word or character) in a string and replace it with another value. The method returns a new string with the replacement and leaves the original unchanged because JavaScript strings are immutable.
1515

1616
Here is the basic syntax:
1717

curriculum/challenges/english/25-front-end-development/review-javascript-strings/6723c1946e4cd7909a836bb4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const text = "HELLO, WORLD!"
9898
console.log(text.toLowerCase()); // "hello, world!"
9999
```
100100

101-
- **The `replace()` Method**: This method is used to find a specified value (like a word or character) in a string and replace it with another value.
101+
- **The `replace()` Method**: This method allows you to find a specified value (like a word or character) in a string and replace it with another value. The method returns a new string with the replacement and leaves the original unchanged because JavaScript strings are immutable.
102102

103103
```js
104104
const text = "I like cats";

curriculum/challenges/english/25-front-end-development/review-javascript/6723d3cfdd0717d3f1bf27e3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ const text = "HELLO, WORLD!"
300300
console.log(text.toLowerCase()); // "hello, world!"
301301
```
302302

303-
- **The `replace()` Method**: This method is used to find a specified value (like a word or character) in a string and replace it with another value.
303+
- **The `replace()` Method**: This method allows you to find a specified value (like a word or character) in a string and replace it with another value. The method returns a new string with the replacement and leaves the original unchanged because JavaScript strings are immutable.
304304

305305
```js
306306
const text = "I like cats";

0 commit comments

Comments
 (0)