登录页面使用多维数组?

login page using multidimensional array?

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 />")
}

这行得通。 0 和 1 索引将被视为用户名,索引 2 将被视为密码。

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")
}