Ok I'm dumb, I exited my for loop too early:

function lookUp( firstName, prop ){
  for( var i = 0; i < contacts.length; i++ ){
    if( firstName == contacts[i].firstName ) {
      if( contacts[i].hasOwnProperty( prop ) ) {
        return contacts[i][prop];
      } else {
        return "No such property";
      }
    }
  }
  return "No such contact";
}

This works.

Answer from dingo_d on Stack Overflow
🌐
freeCodeCamp
forum.freecodecamp.org › guide
freeCodeCamp Challenge Guide: Profile Lookup - Guide - The freeCodeCamp Forum
June 2, 2023 - Profile Lookup Problem Explanation Change the code below // Only change code below this line and up to // Only change code above this line. Ensure that you are editing the inside of the lookUpProfile() function. This function includes two parameters, name and prop.
🌐
CodePen
codepen.io › secan › pen › oLXYvq
FreeCodeCamp : Basic Javascript : Profile Lookup
//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(firstName, prop){ // Only change code below this line var contact; for (var i=0; i<conta
Discussions

Profile lookup on freecode camp checkpoint [closed]
So I'm going through freecodecamp and I'm solving the problems there, to keep in the loop with the programming and I've stumbled on a snag, and I'm not quite sure what's wrong. So I have an array of objects called contacts, and I need to create a function called lookUp(firstName, prop). More on stackoverflow.com
🌐 stackoverflow.com
Javascript Profile Lookup

Where are the contacts object

More on reddit.com
🌐 r/FreeCodeCamp
5
4
December 25, 2021
Basic JavaScript - Profile Lookup
In profile lookup Exercise , I hands on this exercise and I write that code given below. function lookUpProfile(name, prop) { // Only change code below this line for(let i = 0; i More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
December 11, 2022
Build a Profile Lookup - Build a Profile Lookup
Tell us what’s happening: why if statement is not working even when the values in function are correct. Your code so far let contacts = [ { firstName: "Akira", lastName: "Laine", number: "0543236543", likes: ["Pizza", "Coding", "Brownie Points"], }, { firstName: "Harry", lastName: "Potter", ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
3 weeks ago
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
"Profile Lookup" — walkthrough? - JavaScript
September 2, 2017 - Link to challenge: https://www.freecodecamp.org/challenges/profile-lookup I spent a few hours on this but a solution wasn’t clicking. I knew that I had to write an if/else statement but wasn’t sure where to go from ther…
🌐
GitHub
github.com › EQuimper › CodeChallenge › blob › master › javascript › FreeCodeCamps › Basic JavaScript › Profile Lookup.md
CodeChallenge/javascript/FreeCodeCamps/Basic JavaScript/Profile Lookup.md at master · EQuimper/CodeChallenge
//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(firstName, prop){ var msg = 'No such contact'; for (var p in contacts) { if (contacts[p].firstName === firstName && contacts[p].hasOwnProperty(prop)) { msg = contacts[p][prop]; } else if (!contacts[p].hasOwnProperty(prop)) { msg = 'No such property'; } } return msg; // Only change code above this line } // Change these values to test your function lookUpProfile("Harry", "likes");
Author   EQuimper
🌐
Reddit
reddit.com › r/freecodecamp › javascript profile lookup
r/FreeCodeCamp on Reddit: Javascript Profile Lookup
December 25, 2021 -

Hi guys can you tell me what might be wrong with this code? Looked at it for 30 minutes but cant figure out what is wrong here.

function lookUpProfile(name, prop) {
// Only change code below this line
for (let i = 0; i < contacts.length; i++){
if (contacts[i].firstName === name){
if (contacts.hasOwnProperty(prop)) {
return contacts[i][prop];
} else {
return 'No such property';
}
}
} return "No such contact"
// Only change code above this line
}
console.log(lookUpProfile("Kristian", "lastName"))

🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Basic JavaScript - Profile Lookup - JavaScript - The freeCodeCamp Forum
December 11, 2022 - In profile lookup Exercise , I hands on this exercise and I write that code given below. function lookUpProfile(name, prop) { // Only change code below this line for(let i = 0; i < contacts.length; i++) { if(contacts…
Find elsewhere
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Build a Profile Lookup - Build a Profile Lookup
3 weeks ago - Tell us what’s happening: why if statement is not working even when the values in function are correct. Your code so far let 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: ["Intrigui...
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
freeCodeCamp Challenge Guide: Profile Lookup - JavaScript
November 5, 2022 - A lookUpProfile function that takes name and a property (prop) as arguments has been pre-written for you. The function should check if name is an actual contact’s firstName and the given property ...
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Basic JavaScript - Profile Lookup, *help understanding solution* - JavaScript - The freeCodeCamp Forum
May 29, 2023 - Tell us what’s happening: There’s one thing in this code that I don’t understand. In the function “lookUpProfile” I see that if I pass (“Kristian”, “Likes”) it will return Kristian’s likes. However, it still says “retur…
🌐
GitHub
gist.github.com › Renestl › 3167f9b0e6541cedfdb5
Profile Lookup | FreeCodeCamp · GitHub
Profile Lookup | FreeCodeCamp. GitHub Gist: instantly share code, notes, and snippets.
🌐
Stack Overflow
stackoverflow.com › questions › 76625236 › freecodecamp-challenge-basic-javascript-profile-lookup-solution
properties - freeCodeCamp Challenge - Basic Javascript - Profile Lookup Solution - Stack Overflow
function lookUpProfile(name, prop) { // Only change code below this line for (let i = 0; i < contacts.length; i++) { if (contacts[i]["firstName"] === name) { if (contacts[i].hasOwnProperty(prop)) { return contacts[i][prop] } else { return "No such property" } } } return "No such contact" // Only change code above this line }
🌐
GitHub
github.com › Rafase282 › My-FreeCodeCamp-Code › wiki › Lesson-Review-Profile-Lookup
Lesson Review Profile Lookup · Rafase282/My-FreeCodeCamp-Code Wiki · GitHub
January 6, 2017 - function lookUp(firstName, prop) { // Only change code below this line var answer = "No such contact"; contacts.some(function(arg) { if (arg.firstName === firstName && arg.hasOwnProperty(prop) === true) { answer = arg[prop]; } else if (arg.hasOwnProperty(prop) === false) { answer = "No such property"; } }); return answer; // Only change code above this line } // Change these values to test your function lookUp("Kristian", "lastName");
Author   Rafase282
🌐
Medium
medium.com › @kyokyox2 › note-basic-javascript-profile-lookup-951cbd3286c7
[note] Basic JavaScript: Profile Lookup/ freecodecamp | by K | Medium
May 2, 2019 - 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(name, prop){}
🌐
Reddit
reddit.com › r/freecodecamp › js profile lookup exercise
r/FreeCodeCamp on Reddit: JS Profile Lookup exercise
September 27, 2023 -

Hi everyone, I'm new in programming, and I want to ask you if you could tell me why my code doesn't work? I have seen other solutions, and are ok for me, but this code that I made seems ok for me too, but I don't know why it doesn't work.

If I don't write the lasts “else if” and the “else return” the 3 first tests past, but when I try to accomplish the last “No such contact” and “No such property” instructions then the last 3 tests past but not the 3 first test. What am I missing? Thank you for your time.

Here is the link: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/profile-lookup

🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Build a Profile Lookup - JavaScript - The freeCodeCamp Forum
February 17, 2026 - Tell us what’s happening: I’m confused why this works for some prompts like lookUpProfile(“Sherlock”, “likes”) while it doesn’t work for lookUpProfile(“Kristian”, “lastName”). Your code so far let contacts = [ { firstName: "Akira", lastName: "Laine", number: "0543236543", likes: ["Pizza", "Coding", "Brownie Points"], }, { firstName: "Harry", lastName: "Potter", number: "0994372684", likes: ["Hogwarts", "Magic", "Hagrid"], }, { firstName: "Sherlock...