Reverse array javascript

We use arrays in JavaScript to store multiple values. We can easily reverse an array using JavaScript by using reverse() method.

<!DOCTYPE html>
<p>Reverse Array JavaScript Example:</p>
<button onclick="reverseArrayValue()" id="btnClick">Click</button>
<p id="pId"></p>
var season = ["Summer", "Winter", "Monsoon","Spring"];
document.getElementById("pId").innerHTML = season;
function reverseArrayValue() {
document.getElementById("pId").innerHTML = season;

We can able to see how the code is helpful to change the sequence of season.

Leave a Reply

Your email address will not be published. Required fields are marked *