Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Readme update #1332

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

Open
shamimsikder wants to merge 2 commits into TheAlgorithms:master
base: master
Choose a base branch
Loading
from shamimsikder:readme-update
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
View file Open in desktop
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
/**
Copy link
Collaborator

@appgurueu appgurueu Jun 27, 2023

Choose a reason for hiding this comment

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

Unrelated change.

* This function accepts an array and reverses its elements.
* @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
View file Open in desktop
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

AltStyle によって変換されたページ (->オリジナル) /