MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / reverseArray

Function reverseArray

code/solutions/04_2_reversing_an_array.js:1–7  ·  view source on GitHub ↗
(array)

Source from the content-addressed store, hash-verified

1function reverseArray(array) {
2 let output = [];
3 for (let i = array.length - 1; i >= 0; i--) {
4 output.push(array[i]);
5 }
6 return output;
7}
8
9function reverseArrayInPlace(array) {
10 for (let i = 0; i < Math.floor(array.length / 2); i++) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected