diff --git a/1-js/05-data-types/05-array-methods/article.md b/1-js/05-data-types/05-array-methods/article.md index 8536459582..77c9c63381 100644 --- a/1-js/05-data-types/05-array-methods/article.md +++ b/1-js/05-data-types/05-array-methods/article.md @@ -65,7 +65,7 @@ Easy, right? Starting from the index `1` it removed `1` element. In the next example, we remove 3 elements and replace them with the other two: ```js run -let arr = [*!*"I", "study", "JavaScript",*/!* "right", "now"]; +let arr = [*!*"I'm", "studying", "JavaScript",*/!* "right", "now"]; // remove 3 first elements and replace them with another arr.splice(0, 3, "Let's", "dance"); @@ -76,25 +76,25 @@ alert( arr ) // now [*!*"Let's", "dance"*/!*, "right", "now"] Here we can see that `splice` returns the array of removed elements: ```js run -let arr = [*!*"I", "study",*/!* "JavaScript", "right", "now"]; +let arr = [*!*"I'm", "studying",*/!* "JavaScript", "right", "now"]; // remove 2 first elements let removed = arr.splice(0, 2); -alert( removed ); // "I", "study" <-- array of removed elements +alert( removed ); // "I'm", "studying" <-- array of removed elements ``` The `splice` method is also able to insert the elements without any removals. For that, we need to set `deleteCount` to `0`: ```js run -let arr = ["I", "study", "JavaScript"]; +let arr = ["I'm", "studying", "JavaScript"]; // from index 2 // delete 0 // then insert "complex" and "language" arr.splice(2, 0, "complex", "language"); -alert( arr ); // "I", "study", "complex", "language", "JavaScript" +alert( arr ); // "I'm", "studying", "complex", "language", "JavaScript" ``` ````smart header="Negative indexes allowed"