"Basic JavaScript: Profile Lookup" problem is not passing test cases for my code

//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
let noValue= true;
contacts.some((value) => {
    if (value.firstName === name) {
        if (value[prop]) {
            noValue= false;
            return value[prop];
        } else {
            return "No such property";
        }
    noValue= false;
    return true;
    }
});
if (noValue)
  return ('No such contact');
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "likes");

All test cases are passed in console in my local browser. but cant pass in the FCC console. what to do? Help me !

your function returns or undefined or "No such contact", why you may ask, well because the return statements inside some() are for the callback function inside some() not for the lookUpProfile function

it could work using some, certainly, but not in the way you are using it.

the major issue is that you are not doing anything with the returned value of some() and all that stuff inside it is executed but nothing happens with the obtained resultsā€¦

how are you verifying this?
you need to check the value returned from the function call, like console.log(lookUpProfile("Sherlock", "likes"))

1 Like

thanks for your solution. it works and i updated the code structure.