Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme update #1332

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions Data-Structures/Array/Reverse.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/** 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
/**
* This function accepts an array and reverses its elements.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change.

* @param {Array} arr - Array with elements of any data type.
* @returns {Array} - Array with reversed 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--) {
const temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
const reverseArray = (arr) => {
for (let i = 0, j = arr.length - 1; i < j; i++, j--) {
const temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
return arr
}
export { Reverse }
return arr;
};

export default reverseArray;
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ JavaScript Repository of TheAlgorithms, which implements various algorithms and

<h4 align="center">
These implementations are for demonstrative purposes only. Dedicated implementations of these algorithms and data
structures are much better for performance and security reasons. We also do not provide any guarantee for api stability.
structures are much better for performance and security reasons. We also do not provide any guarantee for API stability.
</h4>

---
Expand Down
Loading