So I have the following array defined as follows:
var a = new Array();
a[1] = new Array();
a[1][0] = "Computer Science";
a[1][1] = "Computer Engineering";
a[1][2] = "Aerospace Engineering";
a[1][3] = "Engineering (Other)";
a[1][4] = "Web Development";
a[1][5] = "Computer Programming";
a[1][6] = "Android Development";
//a[2] through a[n] defined similarly
and at one point, I'm trying to test if a string is contained anywhere in a[i], say "Computer Science", so I do the following:
for(j=1; j<n; j++)
if("Computer Science" in a[j])
{
//DO SOMETHING
}
However, this ALWAYS returns false, and yet I've verified that a[j] DOES in fact contain the string (in a[j][0]). Any idea why this is happening?
alert('Computer Science' in ['Computer Science']);
. Nope! Also,new Array()
should probably just be[]
as invar a = [];
.var a=[["computer...","computer...",...["android...]]
like ErikE mentioned in the meantime