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 ...
🌐
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

trying to understand this profile lookup in JavaScript - Stack Overflow
Hello guys I am having some issues understanding this challenge from FreeCodeCamp More on stackoverflow.com
🌐 stackoverflow.com
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 More on stackoverflow.com
🌐 stackoverflow.com
"Profile Lookup" — walkthrough?
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 there. Could you walk me through how to solve it to help me understand the ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
September 2, 2017
freeCodeCamp Challenge Guide: Profile Lookup
Profile Lookup We have an array of objects representing different people in our contacts lists. 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 ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
1
November 5, 2022
🌐
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
🌐
Stack Overflow
stackoverflow.com › questions › 65312020 › trying-to-understand-this-profile-lookup-in-javascript
trying to understand this profile lookup in JavaScript - Stack Overflow
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/profile-lookup · And here is my solution ·
🌐
Gitter
gitter.im › FreeCodeCamp › Help
FreeCodeCamp/Help - Gitter
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){ for(var i=0;i < contacts.length;i++){ if (contacts[i].firstName === firstName) { if(contacts[i].hasOwnProperty(prop)){ return contacts[i][prop]; } else { return "No such property"; } } // Only change code above this line } return "No such contact"; } // Change these values to test your function lookUpProfile("Harry", "likes");
🌐
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…
Find elsewhere
🌐
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 - Solution ahead! 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
🌐
YouTube
youtube.com › we will code
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 javascript and s
Published   March 27, 2017
Views   14K
🌐
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 ...
🌐
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"))

🌐
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 }
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Basic Java Script - Profile Lookup Solution - JavaScript
July 17, 2020 - Hey guys, I’ve got a little problem: i’ve written down a correct solution (when I’m checking it by copying the code to codepen.io and calling the function via console with the given testcases - everythings fine). My code so far: // Setup var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", ...
🌐
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…
🌐
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", …
🌐
Blogger
questionsans.blogspot.com › 2017 › 05 › freecodecamp-profile-lookup-sample.html
Questions and Answers: FreeCodeCamp Profile Lookup Sample Solution
May 11, 2017 - //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 returnValue = ""; for(var i=0;
🌐
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){}