You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: curriculum/challenges/english/blocks/lecture-debugging-techniques/6733aa9b006d29f4d11307a5.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,14 +50,14 @@ This example will result in a `developerObj.map is not a function` error because
50
50
51
51
The last common error we will look at is the `RangeError`.
52
52
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:
54
54
55
55
```js
56
56
constarr= [];
57
57
arr.length=-1;
58
58
```
59
59
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`.
61
61
62
62
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.
63
63
@@ -137,7 +137,7 @@ The error happens because the variable is being treated like a function when it'
137
137
138
138
## --text--
139
139
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`?
0 commit comments