Basic JavaScript - Profile Lookup

Syntax error is showing up at the end where im told not to modify, I imagine something i typed in is causing this. I have looked at CamperBot’s hints and eventually had to resort to the forums see the methods of others, do my best to not go back and look at what they wrote again as i do not want to just copy and I wish to try my best with my own code, but after 3 or 4 hours I am just stumped. Little nudge in the right direction please?

here it what the error says:
SyntaxError: unknown: Unexpected token (42:32)

40 | }
41 |

42 | lookUpProfile(“Akira”, “likes”);
| ^

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 && contacts[i].hasOwnProperty(prop)){
    return contacts[i][prop];
} else if(contacts[i].hasOwnProperty(prop) !== prop) {
  return "No such property";
} else if(contacts[i]['firstName'] !== name){
  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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0

Challenge Information:

Basic JavaScript - Profile Lookup

Lets apply formatting to your code:

function lookUpProfile(name, prop) {
  // Only change code below this line
  for (let i = 0; i < contacts.length; i++) {
    if (contacts[i]['firstName'] === name && contacts[i].hasOwnProperty(prop)) {
      return contacts[i][prop];
    } else if(contacts[i].hasOwnProperty(prop) !== prop) {
      return "No such property";
    } else if(contacts[i]['firstName'] !== name) {
      return "No such contact";
    }
  // Only change code above this line
}

(Note - var is a legacy feature and shouldn’t generally be used)

Count your { and } now. They should look a little funny with this formatting.

I am sorry, this is going to sound so noob-ish but formatting you mean the way I planned and placed everything yes? I’m trying to understand what you mean by :

and as in && is what im thinking but what am i counting or in what way do you mean counting

&& is not { or }.

Count the number of { you typed. Count the number of } you typed. They should always come in matched pairs, but you don’t have the same number of { and }

Just placed. You pushed the loop contents all the way to the left, which makes it hard to see what is supposed to be inside of the loop vs outside.

Ok that was certainly a problem, as i counted them the number of them came out odd so I saw what you meant, could you explain:

&& is not {or}

is it the way i tried to incorporate the && ? From what i read in the instructions both of these requirements must be met for it to return the value of the property though then again i am not confident that i even wrote that part right .
I might need to come back tomorrow or later tonight with a fresh mind, Im just so lost in the sauce and its probably because i’ve been spending hours trying to figure it out though perhaps I pushed my self further away from the concept i’m trying to understand.
If you don’t see a reply from me after this then ya know why lol Thank you Jeremy for your help, i’ll most certainly be looking at your replies when I do come back to this lesson.

I’m honestly not sure what you are talking about with the &&

I don’t understand your sentence here. I don’t know what && has to do with my suggestion that you count the number of { and the number of } you wrote.


You need the number of { and the number of } to match so that your code will run. Once you fix your missing }, then we can debug the logic (its close).

I do apologize. I counted my {} and the number of them came out odd, I rewrote the code the exact same way , but this time i made sure that each { had its partner }.
Nevertheless please understand that I literally have no idea sometimes about the diction that is used or what is implied sometimes so i am going to sound like… well like i dont know anything.
With some rest and a fresh mind I hope i can understand you better.