var arr = [2,1,7,4,5,8]; console.log(arr); console.log(reverseArr(arr)); function reverseArr (arr) { var len = arr.length; for (var i = 0; i < len / 2; i++) { var temp = arr[i]; arr[i] = arr[len-1-i]; arr[len-1-i] = temp; } return arr; }