Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 8, 2020 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/c025e73cb3741b57d11069ea63d7a272 to your computer and use it in GitHub Desktop.
Save codecademydev/c025e73cb3741b57d11069ea63d7a272 to your computer and use it in GitHub Desktop.
Codecademy export
// Write your code here:
function reverseArray(array){
let newArray =[];
array.forEach(element => newArray.splice(0,0,element));
return newArray;
};
// When you're ready to test your code, uncomment the below and run:
const sentence = ['sense.','make', 'all', 'will', 'This'];
console.log(reverseArray(sentence))
// Should print ['This', 'will', 'all', 'make', 'sense.'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment