i had try different way to check if input from the user is in my array.
it seems that is not that simple but i do not understand the exemples.
should i create another array to prompt user input and then compare them.
var userName = prompt("What is your user name?");
var passWord = prompt("Enter your passWord");
// my array
var personInfo = [
["arelys", "are12", 1234],
["jamy", "jamy23", 4567],
["erika", "eri06", 1010]
];
for (var row = 0; row < personInfo.length; row++) {
for (var col = 0; col < personInfo.length; col++) {
personInfo[row][col];
}
// if (userName == personInfo[row].length && userName == personInfo[col].length)
if (userName == personInfo[row][col] && passWord == personInfo[row][col]) {
document.write("found")
} else {
document.write("not found")
}
//document.write("<br />")
}
This will work. 0 and 1 index will be considered as username and index 2 considered as password.
var userName = prompt("What is your user name?");
var passWord = prompt("Enter your passWord");
// my array
var personInfo = [
["arelys", "are12", 1234],
["jamy", "jamy23", 4567],
["erika", "eri06", 1010]
];
var status = 0;
for (var row = 0; row < personInfo.length; row++) {
// if (userName == personInfo[row].length && userName == personInfo[col].length)
if(status !=1){
if ((userName == personInfo[row][1] && passWord == personInfo[row][2]) || (userName == personInfo[row][0] && passWord == personInfo[row][2])) {
document.write("found")
status = 1;
}
}
//document.write("<br />")
}
if(status == 0){
document.write("not found")
}