Skip to content

Instantly share code, notes, and snippets.

@tripdog
Last active June 17, 2021 04:35
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 tripdog/47d32e197d7759ac20187d0f885e0616 to your computer and use it in GitHub Desktop.
Save tripdog/47d32e197d7759ac20187d0f885e0616 to your computer and use it in GitHub Desktop.
Write a function that takes an array and returns a new array that's a reverse of the oringinal.

Write a function that takes an array and returns a new array that's a reverse of the oringinal.

function reverseArray(arr) {
    const newArr = []
    for (i = arr.length - 1; i >= 0; i--){
        newArr.push(arr[i])
    }
    return newArr
}
console.log(reverseArray([3, 4, 5]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment