Profile lookup last 3 tasks

How to complete the last 3 tasks?

  **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 (let i = 0; i < contacts.length; i++) {
  if (name === contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
    return contacts[i][prop];// Only change code above this line
}

lookUpProfile("Akira", "likes");
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 OPR/81.0.4196.60

Challenge: Profile Lookup

Link to the challenge:

What is this comparing if (name !== contacts) ?

What is contacts and could name ever be that?

check my new edit. idk how to write for last 3 tasks

What are the last three tasks? What are you trying to do? What is happening instead? What other things have you tried to accomplish these tasks?

Your edit moved you further from the solution. It is much easier to have a conversation if you make new posts each time instead of editing the first post over and over again.

I’m sorry. i thought it will be easier to edit rather than delete and make a new post

Woops, words mixup on my part. You shouldn’t make a new post. You should make new replies to this same post.

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

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

lookUpProfile("Akira", "address") should return the string No such property

i copy pasted the tasks from the challange.

What do you get when you run lookUpProfile("Bob", "number")?
What do you get when you run lookUpProfile("Bob", "potato")?
What do you get when you run lookUpProfile("Akira", "address")?

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