I am making a local login using JavaScript and I need to know the fastest way to scan an array.
Say there are two arrays:
usernames = ["uname 1", "uname 2", "uname 3"];
passwords = ["pswd 1", "pswd 2", "pswd 3"];
And there are two HTML inputs
<input id="username">
<input id="password">
I need to know the fastest way to see if the value from the HTML inputs matches any username and password.
I have tried a while function:
while(counter1 < usernames.length){
//testing goes here
counter ++;
}
And an "if / repeate" function
if(counter1 < usernames.length){
//testing goes here
setTimeout(currentFunction, 1);
}
This is not a duplicate of the question "What's the fastest way to loop through an array in JavaScript?" because I am open to more than a
for
loop