Profile lookup passes invalid code.
See original GitHub issueChallenge Name
Profile Lookup
Issue Description
The test for no such property passes even when the code does check firstName value. Because the test for no such property uses the first contact in the array the test will pass even if the code does not check for matching first name
Browser Information
Chrome on windows - 52.0.2743.116
Your Code
This code passes but shouldn’t per instructions
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i< contacts.length; i++){
if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
if(contacts[i].hasOwnProperty(prop) === false) {
return "No such property";
}
}
return "No such contact";
// Only change code above this line
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
freeCodeCamp Challenge Guide: Profile Lookup
Can anyone tell please what's wrong with my code? why is my "Profile lookup" challenge code doesn't work? Why is this code not...
Read more >Profile Lookup - Free Code Camp - YouTube
In this tutorial called Profile Lookup, we iterate through an array of objects and test those objects to see if they fit specific...
Read more >Profile Lookup, freeCodeCamp Basic Javascript - YouTube
Show your Support, Buy a Sticker! https://believerationally.com/shopIn this challenge, we learn how to look through an array of contacts in ...
Read more >Why do I see the error “The passcode you entered is invalid ...
You entered the passcode incorrectly. Please verify that you entered a valid passcode. No space should be included between characters when you input...
Read more >Troubleshooting verification code issues - Microsoft Support
Learn what you can do if you're not receiving account aign-in verification codes.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The change provided didn’t test the case indicated. The property “number” is on every contact, the new test should have been something like profileLookup(“Bob”, “email”)
The instructions are fine, you need another test to stop people from passing with bad code if you test it against lookupProfile(“Bob”, “likes”), the bad example above will return Akira’s likes. Simply adding another test to pass will close this. Add this test @Bouncey.