"Profile Lookup "Problem

Tell us what’s happening:

I don’t understand why my code doesn’t work

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 "No such contact";
    } else {
            return "No such property";
        } else {
            return contacts[i][prop];
// Only change code above this line

lookUpProfile("Akira", "likes");

Your browser information:

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

Challenge: Profile Lookup

Link to the challenge:

Hello and welcome to the forum!

This condition right here is your trouble. You will return the very first time you find a name that does not match, which isn’t what you want.

Lol, what an idiot I am… Thank you, man!


You’re making mistake here, you used return which will return on the first loop if not found.

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

Again sorry, its mean I should stop looking here, thanks!

Little mistakes happen to all of us while coding. I’m glad that I could help!