Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d9edf75

Browse files
Create slicearray.js
1 parent 163688e commit d9edf75

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎Javascript/slicearray.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*Complete the function named subarray() in which you are given an array named arr, and two integers start, end. You need to implement the function to return a subarray starting from index start and ending on index end.
2+
3+
4+
Note: Use the slice method of Array.
5+
*/
6+
function subarray(arr, start, end) {
7+
8+
let result = arr.slice(start,end+1)
9+
return result
10+
}
11+
12+
const arr = [[2, 1, 1, 3, 4, 5, 5, 6, 7, 8, -1100 , 9, 8], 4, 10]
13+
const start= 1
14+
const end= 3
15+
16+
console.log(subarray(arr, start, end))
17+
module.exports = subarray;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /