Advertisement
GamerBhai02

Program 13 Delete Last Element in Array

Dec 5th, 2024 (edited)
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.72 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Delete Last Element from Array</title>
  5.     <script>
  6.         var array = [10, 20, 30, 40, 50];
  7.         function getArray() {
  8.             document.getElementById("OriginalArray").innerHTML = "Original Array: " + array;
  9.         }
  10.         function deleteLastElement() {
  11.             array.pop();
  12.             document.getElementById("ModifiedArray").innerHTML = "Modified Array: " + array;
  13.         }
  14.     </script>
  15. </head>
  16. <body>
  17.     <h1>Delete Last Element From An Array</h1>
  18.     <button onclick="getArray()">Get Array</button>
  19.     <p id="OriginalArray"></p>
  20.     <button onclick="deleteLastElement()">Delete Last Element</button>
  21.     <p id="ModifiedArray"></p>
  22. </body>
  23. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement