Basic JavaScript - Profile Lookup

Tell us what’s happening:
Describe your issue in detail here.
So everything seems to be working except returning the value of the property. I don’t know what, if anything is being returned since it only tells me that the correct answer didn’t show up but my language is identical to some of the hints (return contacts[i][prop];). I want to know what I’m doing wrong here that’s causing the prop to not show up.

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 (contacts[i].firstName != name) {
      return "No such contact";
    else {
      if (contacts[i].hasOwnProperty(prop)) {
        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/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15

Challenge: Basic JavaScript - Profile Lookup

Link to the challenge:

Answer me this. How many times is your for loop ever going to actually loop?

Hint: It does not depend on the number of items in the contacts array.

Okay, I think I understand what you mean. Thanks!

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