var pov=[]; for (i=0;i<c.length; i++) { k=0;m=1; if(u[k]==c[0]&&u[m]==c[2]){ pov.push(c[i]); }} document.write(pov);