Skip to content

Commit cce4f57

Browse files
fix(curriculum): clarify RangeError example in debugging lecture (freeCodeCamp#63964)
1 parent 014882c commit cce4f57

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

curriculum/challenges/english/blocks/lecture-debugging-techniques/6733aa9b006d29f4d11307a5.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ This example will result in a `developerObj.map is not a function` error because
5050

5151
The last common error we will look at is the `RangeError`.
5252

53-
A `RangeError` happens when your code tries to use a value that’s outside the range of what JavaScript can handle. Here is an example of trying to assign an invalid index to the length of the array:
53+
A `RangeError` happens when your code tries to use a value that’s outside the range of what JavaScript can handle. Here is an example of assigning an invalid value to an array's length:
5454

5555
```js
5656
const arr = [];
5757
arr.length = -1;
5858
```
5959

60-
Since `-1` is not a valid index used for arrays, this will result in a `RangeError`.
60+
Since an array's `length` has to be a non-negative integer, setting it to `-1` triggers a `RangeError`.
6161

6262
As you continue to program in JavaScript, just be aware of these different types of errors you will probably encounter and why they are happening.
6363

@@ -137,7 +137,7 @@ The error happens because the variable is being treated like a function when it'
137137

138138
## --text--
139139

140-
Which error occurs when you try to access an array index that doesn't exist?
140+
Which error occurs when you assign an invalid value, such as `-1`, to an array's `length`?
141141

142142
## --answers--
143143

0 commit comments

Comments
 (0)