Profile Lookup - unknown error

hi guys, I was trying to solve profile lookup exercise but could not find why this code not getting me the required results kindly help me out.

Welcome.

Provide link to the challenge please.

And instead of screenshots, you can post your code.

Press ctrl-e when writing post to make code look like:

this

Your code only iterates one time before a value is returned. Once a return statement is executed, the function exits immediately whether or not the loop was finished. You need to rethink your logic here a little bit.

here is the link ,
next time i will surely post the code.

You have to post the code here. We can not see your code on the FCC site.

thankyou sir, it helped but part of the code still not working . Instead of returning i assigned the values to a variable and then returned that variable after the code ends.

We are unable to help without see the latest version of your code. Please post it in a reply. Thank you.

function lookUpProfile(name, prop) {
  var result = " ";
  // Only change code below this line
for (let i = 0; i<contacts.length; i++){

    if(contacts[i]["firstName"] == name && contacts[i].hasOwnProperty(prop) == true){
      result = contacts[i][prop];
    
    }else if( name != contacts[i]["firstName"] ){
      result = "No such contact";

    }else {
      result = "No such property";
    }
    
}
    return result; 
  // Only change code above this line
}

also, here is the wrong parts i am stuck with

let’s say this is true
but then next iteration, it’s false

so this one execute, overwriting result

thankyou, so much sir i got it now .