Skip to content

Instantly share code, notes, and snippets.

@caglarorhan
Created February 15, 2018 20:00
Show Gist options
  • Save caglarorhan/139ece3f0dd59889b54651332078885d to your computer and use it in GitHub Desktop.
Save caglarorhan/139ece3f0dd59889b54651332078885d to your computer and use it in GitHub Desktop.
Reverse an array with pop and push
var A = [1,2,3,4,5,6,7,8,9];
var x =[];
x.push(A.pop());
x.push(A.pop());
x.push(A.pop());
x.push(A.pop());
x.push(A.pop());
x.push(A.pop());
x.push(A.pop());
x.push(A.pop());
x.push(A.pop());
console.log(x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment