So, how would you remove all objects from an array.. My current code is:
var array = [""];
function add() {
var input = document.getElementById("enterInput").value;
array.push(input);
var arrayOut = document.getElementById("output").innerHTML = array;
}
function clearit() {
var length = array.length;
array.splice(0, length, length);
array.push("");
}
Thanks, Noah..
(and yes, I have checked the console and no errors are returned.)
Answer
Just use
function clearit() {
array = []; //or array = [""];
}
No comments:
Post a Comment