Comes up that ¨bob¨ ¨number¨should return ¨No such property¨

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

// Setup
const 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) {
  if (prop in contacts[i]) {
    return contacts[i][prop];
}else{
  return "No such property"
}
  
    }
    }



// Only change code above this line
}
lookUpProfile("Akira", "likes",);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36

Challenge: Profile Lookup

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.


You shouldn’t be using var. Use let.

Does this actually do what you think it does? This doesn’t seem valid to me.

Well I use in operator instead a hasOwnProperty but even change the var for let and use the hasOwnProperty still coming this error that is no returning “No such Property” on “Bob” "number

Huh, never head of the in operater before. Learn something every day.

Your title isn’t quite right

lookUpProfile("Bob", "number") should return the string No such contact

Nowhere do you return “No such contact”.

My issue is I don’t see why when I run the test, all works fine just the two supposed to return "No such contact"doesn’t work must be something that is placed on the wrong space

Where are you returning ‘No such contact’? Can you show m’ which line does this?

Captura de pantalla 2022-01-23 a las 19.50.58

Where in your code are you returning the string ‘No such contact’?

Just solved when I post it I realize that I didn’t place the return no such contact out of the loop

1 Like

thank you very much without you ,asking me to post you the code I would never realized

1 Like