Hey all,
So I’m currently attempting the Profile Lookup challenge. I started it last night, but couldn’t get anywhere. However, I’ve made some progress today thanks to reading some of the previous threads of users who were in the same situation as I am. Plus, the hints offered on the Profile Lookup challenge guide were also helpful.
Here is my code as it is right now:
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) {
if (firstName === contacts[i].firstName) {
if (contacts[i].hasOwnProperty(prop) === true) {
return contacts[i].prop;
} else {
return "No such property";
}
}
}
return "No such contact";
// Only change code above this line
}
So far, I have been able to complete the last two parts of this challenge:
“Kristian”, “lastName” should return “Vos”
“Sherlock”, “likes” should return [“Intriguing Cases”, “Violin”]
“Harry”,“likes” should return an array
(Y) - “Bob”, “number” should return “No such contact”
(Y) - “Akira”, “address” should return “No such property”
I know I’m on the right track and that I need to tweak something in my current code in order to meet all the criteria for this challenge. However, I’m not sure which part(s) I need to tweak in order to accomplish that. What suggestions or recommendations would you like to offer that will guide me in the right direction?
Thanks to all who responded. I appreciate your input!