I am looking for somebody to partner program profile lookup challenge

I am looking for somebody to partner program profile lookup challenge
0

#1

Hello, Is anyone on profile lookup javascript challenge? I am looking for somebody to partner program so we can help each other.


#2

I am trying this code out…but it does not work…

for (var i = 0; i < 4; i++) {
if (firstName == contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
console.log(contacts[i][prop]);
} else {
console.log(“No such property”);
}
} else {
console.log(“No such contact”);
}
}


#3

I know what the problem was, it was failing to find “Harry” “likes” because it returned “No such contact” after a single iteration of the loop. Now, I shifted the return “No such contacts” to the end, after the for-loop has finished all iterations, and this solves the problem :slight_smile:

for (var i = 0; i < 4; i++) {
if (firstName == contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return “No such property”;
}
}
}
return “No such contact”;