I'm trying to fix my push method in my if statement. My statement looks like this:
var lookup = [];
for(key in JSON){
var category = JSON[key].Category;
if(!(category in result)){
lookup.push(category);
myVar+=
"<tr>"+
"<td align='left'><input type='checkbox' name='comp' id='sub0' class='communication' value='1t'/>"+category+"</td>"
"</tr>"
}
}
What I'm trying to do here is if record already exist in lookup value will not be printed out again, if not then will print the value and push in lookup array. My current code is repeating values. I think that my if statement or my push method does not work properly. If anyone can help and tell me what I'm doing wrong I would appreciate. Thank you.