Return contacts[i][prop] isn't returning values

Tell us what’s happening:

return contacts[i][prop] isn’t returning values
I keep getting these errors

“Kristian”, “lastName” should return “Vos”

“Sherlock”, “likes” should return [“Intriguing Cases”, “Violin”]

“Harry”, “likes” should return an array

Your code so far


// 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(name, prop){
// Only change code below this line
for (var i = 0; i < contacts.length; i++) 
{

if(contacts[i]["firstName"] == name){

return  contacts[i][prop] || "No such property";
  
}

return "No such contact"; 

}

// Only change code above this line
}

lookUpProfile("Akira", "likes");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.

Challenge: Profile Lookup

Link to the challenge:

You are returning the first time that you encounter a name that does not match. You want to move your

return "No such contact"; 
2 Likes

I feel u should replace the kali braces with a dot(.) .Firstname

1 Like

I don’t understand you.

I just fixed it. Thank you, i had to move return “No such contact” a little further down.

1 Like