my code only prints the last value of the array
问题 I made a variable and added new values with the push attribute but when the for-loop calls it one-by-one it only prints the last value(name) that is "Pranav". Can you help me to know how to fix it and print all the values one-by-one. function tryme() { var names = new Array(); names.push("Bhavesh", "Ajay", "Rahul", "Vinod", "Bobby", "Pranav"); var tryit = document.getElementById("tryit"); for (i = 0; i < names.length; i++) { tryit.innerHTML = "The values are " + names[i] + " . <br>" }; }; 回答1