mercredi 29 juin 2016

Javascript for if statement works outside function but not inside

Can't seem to figure out why my code works outside of a function but not inside.

Outside:

for(var j=0; j<contacts.length; j++){
    if(contacts[j].hasOwnProperty("like")===false) {
      console.log("No such property");
    } 
  }

Inside:

function lookUpProfile(fN, prop){

for(var j=0; j<contacts.length; j++){
    if(contacts[j].hasOwnProperty("like")===false) {
      console.log("No such property");
    } 
  }
} 

Aucun commentaire:

Enregistrer un commentaire