diff --git a/Data-Structures/Array/Reverse.js b/Data-Structures/Array/Reverse.js index 79a789c017..baddc13a93 100644 --- a/Data-Structures/Array/Reverse.js +++ b/Data-Structures/Array/Reverse.js @@ -8,9 +8,12 @@ const Reverse = (arr) => { // limit specifies the amount of Reverse actions for (let i = 0, j = arr.length - 1; i < arr.length / 2; i++, j--) { - const temp = arr[i] - arr[i] = arr[j] - arr[j] = temp + if(i!=j) + { + arr[i] = arr[i]^arr[j]; + arr[j] = arr[i]^arr[j]; + arr[i] = arr[i]^arr[j]; + } } return arr }