Profile Lookup test case fails

Tell us what’s happening:
In profile lookup task, I can able to get the correct data when I am consoling it return No such contact , But If I return result I got out all test cases the test only pass for No such contact. I want to know where I am wrong. Can any one help me ?

Thanks in advance!

Your code so far

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 result;
//  console.log("Firstname",firstName);
   if(contact.firstName === firstName){
//        console.log("Contact",contact);
     if(contact[prop] !== undefined){
//          console.log("Prop",contact[prop]);
         result = contact[prop];  
          result = "No such property";
         result = "No such contact";
  return result;

// Only change code above this line

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36.

Link to the challenge:

The variable result is only returned after the entire array has been searched. Think about what happens with Sherlock - he’s found on the third try and result is given his likes. However, the code doesn’t stop and the next profile is searched. Since the names don’t match, result becomes “No such contact”, which eventually gets returned.

1 Like

Thank you so much, If you don’t mind means can you explain breifly