Profile Lookup confuses with same param name and attribute name
See original GitHub issueChallenge Profile Lookup has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];
function lookUpProfile(prop1, prop2){
// Only change code below this line
var i = 0;
while(i != contacts.length) {
if(contacts[i].firstName == prop1){
if(contacts[i][prop2]){
return contacts[i][prop2];
}else{
return "No such property";
}
}
i++;
}
return "No such contact";
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");
In the Profile Lookup challenge code, the lookUpProfile function’s first parameter name is “firstName” which is the same as the array objects “firstName” properties.
The problem is that a novice learner like myself can pass the test without even realizing that the lookUpProfile function’s first parameter “firstName” is not at all the same thing as the array objects “firstName” properties. It’s really easy to assume they are one and the same.
I propose we change the lookUpProfile function’s parameter “firstName” to something like “prop1” (for example like I have it posted here in the code above). Honestly, while I was solving this challenge it was very confusing at first until I realized that “firstName” was used for two different things (function parameter and the array objects properties) in the code.
Any thoughts or other suggestions.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)

Top Related StackOverflow Question
Hi, just sent a pull request with the fix for this
Agreed @systimotic