Skip to content

Commit c41d288

Browse files
reverse array javascript program
1 parent 1710b0d commit c41d288

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ReverseArray.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Complete the 'reverseArray' function below.
3+
*
4+
* The function is expected to return an INTEGER_ARRAY.
5+
* The function accepts INTEGER_ARRAY a as parameter.
6+
*/
7+
8+
function reverseArray(a) {
9+
// Write your code here
10+
let arr2 = [];
11+
12+
for(let i = a.length - 1; i >= 0; i--){
13+
arr2.push(a[i]);
14+
}
15+
16+
return arr2
17+
}
18+
19+
console.log(reverseArray([1,2,3,4,5]))

0 commit comments

Comments
 (0)