fix(curriculum): clarify that replace() returns a new string in JS lesson (#61730)

Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com>
Co-authored-by: Ilenia M <nethleen@gmail.com>
This commit is contained in:
Niloy Saha
2025-08-24 00:19:20 +06:00
committed by GitHub
parent 7c25ffc556
commit 1cca628c54
3 changed files with 3 additions and 3 deletions

View File

@@ -11,7 +11,7 @@ In JavaScript, there are many scenarios where you may need to replace a portion
For instance, you might need to update user information in a URL, change the formatting of dates, or correct errors in user-generated content.
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 `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.
Here is the basic syntax:

View File

@@ -98,7 +98,7 @@ const text = "HELLO, WORLD!"
console.log(text.toLowerCase()); // "hello, world!"
```
- **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.
- **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.
```js
const text = "I like cats";

View File

@@ -300,7 +300,7 @@ const text = "HELLO, WORLD!"
console.log(text.toLowerCase()); // "hello, world!"
```
- **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.
- **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.
```js
const text = "I like cats";