Associative arrays in javascript look like this: var myAssoc = {"key1":"val1","key2":"val2"}
To get a value, given a key, you would write: myAssoc[key]
So what are associative arrays?
The short answer is that they are lists of key, value pairs. In javascript, everything is really just an object. So another way to put it is that they are objects with properties.
//students on the roll
var roll = ["robert","joe","sharon"];
//students actually in the class
var students = {"sharon":true, "robert":true};
//Loop over the roll array. For each name in the roll array, check if
//that name exists in the students associate array.
//Whenever you find a student that is present, increment the numPresent
//counter by 1
var numPresent = 0;
for (i=0;i<roll.length;i++){
if(students[roll[i]]===true){
numPresent++;
}
}