Files
Hasan Al-Kaf 6fe21d21e9 chore: convert functions to an ES2015 classes (#1656)
* chore: convert functions to an ES2015 classes

* remove unnecessary functions
2024-04-13 23:21:54 +05:30

16 lines
512 B
JavaScript

/** https://www.geeksforgeeks.org/write-a-program-to-Reverse-an-array-or-string/
* This function will accept an array and
* Reverse its elements and returns the inverted array
* @param {Array} arr array with elements of any data type
* @returns {Array} array with inverted elements
*/
const Reverse = (arr) => {
// limit specifies the amount of Reverse actions
for (let i = 0, j = arr.length - 1; i < arr.length / 2; i++, j--)
[arr[i], arr[j]] = [arr[j], arr[i]]
return arr
}
export { Reverse }