Skip to content

Instantly share code, notes, and snippets.

@Spec007
Spec007 / reversearray.js
Created February 18, 2017 06:07
Eloquent Javascript: Reversing an Array
/* For this exercise, write two functions, reverseArray and
reverseArrayInPlace. The first, reverseArray, takes an array
as argument and produces a new array that has the same
elements in the inverse order. The second, reverseArrayInPlace,
does what the reverse method does: it modifies the array given
as argument in order to reverse its elements. Neither may use
the standard reverse method. */
function reverseArray(array) {
var newArray = [];