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.


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:


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

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.

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 .

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.