Lookup challenge

please what is wrong with my code.i’m confused already

  **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 (firstName === contact[i].firstName) {
      if (contacts[i].hasOwnProperty(prop)) { 
        return contacts[i][prop]; 
        } else {
          return "No such contact";
// Only change code above this line

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

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0

Challenge: Profile Lookup

Link to the challenge:

Could you be more specific? In what cases is it failing? How is it failing?

SyntaxError: unknown: Unexpected token (43:32)

41 | }
42 |

43 | lookUpProfile(“Akira”, “likes”); that is the error i am getting

Several things:

  1. You’re missing two curly brackets (hence the error), one for closing the loop and the other for the function;
  2. In the first if statement, you’re comparing firstName which isn’t defined as such (it exists on contacts object) and I’m assuming it’s a typo, you want to compare name which is the first argument passed into the function;
  3. You’re returning “No such contact” after checking for the prop/property;

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