We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 41752bf commit d749f6aCopy full SHA for d749f6a
slice.js
@@ -0,0 +1,15 @@
1
+Array.prototype.ownSlice = function ownSlice (str, end) {
2
+ const arr = this;
3
+ const result = [];
4
+
5
+ if (Array.isArray(arr)) {
6
+ const loopContinue = end > arr.length ? arr.length : end;
7
+ for (let i = str; i < loopContinue; i++) {
8
+ result.push(arr[i]);
9
+ }
10
11
+ return result;
12
+}
13
14
+const arr = [1,2,3,4,5];
15
+console.log(arr.ownSlice(2,4))
0 commit comments