I am saving some data in order using arrays, and I want to add a function that the user can reverse the list. I can’t think of any possible method, so if anybody knows how, please help.
I am saving some data in order using array s, and I want to
Share
Javascript has a
reverse()method that you can call in an arrayNot sure if that’s what you mean by ‘libraries you can’t use’, I’m guessing something to do with practice. If that’s the case, you can implement your own version of
.reverse()Do note that the built-in
.reverse()method operates on the original array, thus you don’t need to reassigna.