hw06_09.html 785 B

12345678910111213141516171819202122232425262728293031
  1. <header>
  2. <h1>Reverse 2</h1>
  3. </header>
  4. <body>
  5. <script>
  6. const arr = [];
  7. arr.push(prompt("Enter element 1"));
  8. arr.push(prompt("Enter element2"));
  9. arr.push(prompt("Enter element 3"));
  10. arr.push(prompt("Enter element 4"));
  11. arr.push(prompt("Enter element 5"));
  12. alert(arr);
  13. const arr2 = [];
  14. arr2.push(arr.pop());
  15. arr2.push(arr.pop());
  16. arr2.push(arr.pop());
  17. arr2.push(arr.pop());
  18. arr2.push(arr.pop());
  19. alert(arr2);
  20. alert(arr);
  21. arr.unshift(arr2.shift());
  22. arr.unshift(arr2.shift());
  23. arr.unshift(arr2.shift());
  24. arr.unshift(arr2.shift());
  25. arr.unshift(arr2.shift());
  26. alert(arr);
  27. alert(arr2);
  28. </script>
  29. </body>