12345678910111213141516171819202122232425262728293031 |
- <header>
- <h1>Reverse 2</h1>
- </header>
- <body>
- <script>
- const arr = [];
- arr.push(prompt("Enter element 1"));
- arr.push(prompt("Enter element2"));
- arr.push(prompt("Enter element 3"));
- arr.push(prompt("Enter element 4"));
- arr.push(prompt("Enter element 5"));
- alert(arr);
- const arr2 = [];
- arr2.push(arr.pop());
- arr2.push(arr.pop());
- arr2.push(arr.pop());
- arr2.push(arr.pop());
- arr2.push(arr.pop());
- alert(arr2);
- alert(arr);
- arr.unshift(arr2.shift());
- arr.unshift(arr2.shift());
- arr.unshift(arr2.shift());
- arr.unshift(arr2.shift());
- arr.unshift(arr2.shift());
- alert(arr);
- alert(arr2);
- </script>
- </body>
|