question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Profile lookup passes invalid code.

See original GitHub issue

Challenge 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sjames1958gmcommented, Nov 28, 2016

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”)

0reactions
rgtalbotcommented, Nov 10, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found