To reverse the order of items in an array, we can make use of the built-in reverse() method and this method will work perfectly without any issue.
In the following example, we have one global array of numbers. We will display all the items on the screen in a list format. Upon click of a button, we will reverse the order of the items. Please have a look over the code example and the steps given below.
HTML & CSS
We have 2 elements in the HTML file (button and ul).
The innerText for the button element is “Reverse Array”.