Exercise:
Use the push() method to add a new item to fruits:
Kiwi
.
Edit This Code:
See Result »
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var fruits = ["Banana", "Orange", "Apple"]; document.getElementById("demo").innerHTML = fruits; </script> </body> </html>
Result:
Show Answer
Correct Code:
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> var fruits = ["Banana", "Orange", "Apple"]; fruits.push("Kiwi"); document.getElementById("demo").innerHTML = fruits; </script> </body> </html>
Correct Result:
Hide Answer
Privacy Policy