Thursday, June 7, 2012

[Action Script] Checking user names with for each loop and if . . . June,2012

I've set up a web site so that my users can log in if they have a password that matches one from my list of possible passwords.(hypothetical).

with out using a function and only using a for each loop and if, how do I check if userEnterName matches any of the four in nameCheck?

var nameCheck:Array = ["cowboy", "spaceman", "lowboy", "1withmany"];
var userEnterName:String = "";

for each(var n:String in nameCheck){
if(n == nameCheck[0],[1]){
trace("The password was found in the list");
}
else{
trace("The password was not in the list");
}
}
Checking user names with for each loop and if . . .

Related Post



0 comments: