Skip to content

Instantly share code, notes, and snippets.

@caglarorhan
Created February 15, 2018 19:52
Show Gist options
  • Save caglarorhan/79e990943f8bd810af777f2a4ebef83b to your computer and use it in GitHub Desktop.
Save caglarorhan/79e990943f8bd810af777f2a4ebef83b to your computer and use it in GitHub Desktop.
Reverse an array using for loop, pop and push
var A = [1,2,3,4,5,6,7,8,9];
var B=[];
var ALength = A.length;
for(var xcv=1;xcv<=ALength;xcv++) {
B.push(A[ALength-xcv]);
}
console.log(B);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment