Basic JavaScript - Profile Lookup

Hello!

I can’t see what’s going wrong here… I’ve looked at many of the other forum posts but can’t seem to find a solution. Was wondering if someone could point out the issue?

Thank you in advance! :slight_smile:

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

  var output;

  for (let i = 0; i < contacts.length; i++) {
    if (contacts[i]["firstName"] == name && contacts[i].hasOwnProperty(prop) == true) {
      output = contacts[i][prop];
  } else if (contacts[i]["firstName"] == name && contacts[i].hasOwnProperty(prop) == false) {
      output = "No such property";
  } else {
      output = "No such contact";
  }
}
return output;
  // 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/106.0.0.0 Safari/537.36 Edg/106.0.1370.42

Challenge: Basic JavaScript - Profile Lookup

Link to the challenge:

step one: Determine if name is a real contact
step two: Determine if name have prop
step three: if contact is true and prop is ture, return real prop value or “No such property”
step four: if name is not real contact return “No such contact”

The order of the search requires you to compare carefully again

Hi, thank you! Have worked it out, I altered my return statements slightly :slight_smile:

Hi @katieve :wave: .
**Good job so far :+1: **

Let’s take a look at what we are dealing with here.


Please try to solve it before copying the entire  code below

Redacted all the code posted here

Thank you buddy :+1:
You go this :+1: .
@Oluyemi

hi again,

I’m not sure why you are continuing to post code in response to requests for help on the forum?
We want people to help each other and it seems you have already done that here in your previous posts so I see no purpose to posting this code to this topic. The code has been removed.

thanks

1 Like

Hi @hbar1st :wave:
Thank very much @hbar1st .
I am not aware of this development
I appreciate if you could give more details about this.
I might want to come soft when next your voice seem a lit bit rough.

I will sincerely appreciate your feedback.
thanks :+1:

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thanks @hbar1st :+1:
I appreciate you.
I will try not to post full solution again

1 Like

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