<!DOCTYPE html>
<html>
<body>
<p>Click the button to add a new element to the array.</p>
<input type="text" id="name">
<button onclick="myFunction()">insert</button>
<p id="demo"></p>
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
var data1 = document.getElementById("name").value;
fruits.push(data1);
document.getElementById("demo").innerHTML = fruits;
}
</script>
</body>
</html>
<html>
<body>
<p>Click the button to add a new element to the array.</p>
<input type="text" id="name">
<button onclick="myFunction()">insert</button>
<p id="demo"></p>
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
var data1 = document.getElementById("name").value;
fruits.push(data1);
document.getElementById("demo").innerHTML = fruits;
}
</script>
</body>
</html>