The code below is showing this result by all indications the code is correct// running tests lookUpProfile("Kristian", "lastName") should return the string Vos

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

// Setup
var 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) {
  for(let  i=0;i <contacts.length;i++){
      if (contacts[i].firstName===name){
          if (prop in contacts[i]) {
                return contacts[i][prop];


              return "No such property"



      return "No such contact";

// Only change code below this line

// Only change code above this line

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

User Agent is: Mozilla/5.0 (Linux; Android 10; TECNO B1g) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.96 Mobile Safari/537.36

Challenge: Profile Lookup

Link to the challenge:

Hello! It looks like the problem here is that currently if contacts[i].firstName does not equal name, it will return “No such contact”. You need to change your code so that return “No such contact” is not part of the for loop.

Hope this helps!

1 Like

Doing that console returned function need to return"No such contact" The code I submitted is the same code in the Help forum. It works on other JS console.

If you are referring to Solution 2 on the hints page, no, your code is not quite the same as that solution. As @eygis pointed out, you don’t want return "No such contact" to be part of the for loop. It might help if you formatted your code a little better, lining up the indents correctly, so that you can see where the for loop ends.

1 Like

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