Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <p>Click the button to add elements to the array.</p>
- <button onclick="myFunction()">Try it</button>
- <p id="demo"></p>
- <script>
- var fruits = ["Banana", "Orange", "Apple", "Mango"];
- document.getElementById("demo").innerHTML = fruits;
- function myFunction() {
- fruits.splice(2, 0, "Lemon", "Kiwi");
- document.getElementById("demo").innerHTML = fruits;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement