I am new to javascript and so far it is my understanding that:
?
& :
is used for "if true, do this, if false do this"
However, I am having a little more trouble with ||
. From my browsing it seems something like "if the first one is true do that, otherwise do this"
I am trying to figure out the following code - any suggestions on what they mean together in this context?:
function isSubset(series, description){
var subset = true;
var exactMatch = true;
demoCodes = ['age', 'edu', 'race', 'sex'];
for (var i = 0; i < demoCodes.length; i++){
var demoCode = demoCodes[i];
subset = (subset) ? (description[demoCode] == 0 || description[demoCode] == series[demoCode]) : false;
exactMatch = (exactMatch) ? description[demoCode] == series[demoCode] : false;
}
return {subset: subset, exactMatch: exactMatch};
}
Thanks! Cheers