I found the problem :’) it took me too long. i just forgot the closing bracket of the for loop
this is my code that dosen’t work
function lookUpProfile(name, prop){
for(var i=0; i<contacts.length;i++){
if(contacts[i]["firstName"] == name){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return "No such property";
}
}
return "No such contact";
}
and this is the answer
function lookUpProfile(name, prop) {
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName === name) {
if (prop in contacts[i]) {
return contacts[i][prop];
} else return "No such property";
}
}
return "No such contact";
}
so what is the difference why mine dosen’t work is there some kinda bug that i didn’t notice