Problem is, I make an empty array and it stays empty until a user is on my page and inputs their "username" and their "ID" and clicks a button.
I have to check the array for duplicates so I want my code to check the array, if nothing with the same name exists then add it into the array. Here is my code that does not work
var myArray = [];
function arrayChecker(inputName, inputID) {
for (var key in myArray) {
if (myArray.hasOwnProperty(key)) {
console.log(key, myArray[key]);
} else {
myArray.push({"name": inputName, "id": inputID});
}
}
}
This does not work however. Any ideas?