# Partial working. Contacts task

**URL:** <https://forum.freecodecamp.org/t/partial-working-contacts-task/410844>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [July 21, 2020, 1:45am UTC](https://forum.freecodecamp.org/t/partial-working-contacts-task/410844 "2020-07-21T01:45:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cristianca84](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Cristianca84](https://forum.freecodecamp.org/u/Cristianca84)\
**Post date:** [July 21, 2020, 1:45am UTC](https://forum.freecodecamp.org/t/partial-working-contacts-task/410844/1 "2020-07-21T01:45:30Z")

</div>

Hello. I would want to know what is wrong with my code. It seems to work with the first contact, but it doesn´t with the other ones.

Task: The function should check if `name` is an actual contact’s `firstName` and the given property ( `prop` ) is a property of that contact.

If both are true, then return the “value” of that property.

If `name` does not correspond to any contacts then return `"No such contact"` .

If `prop` does not correspond to any valid properties of a contact found to match `name` then return `"No such property"` .

This is my script:

```auto
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){

// Only change code below this line

  for (var i=0; i < contacts.length; i++) {

//for (var j=0; j < contacts[i].length; j++) {

  //console.log(contacts[i]);

    if (contacts[i].firstName === name) {

    

    // | significa y si no se cumple la condición

      return contacts[i][prop];

    } else if (contacts[i].firstName !== name) {

        return "No such property";

    } else {

      return "No such contact";

    }  

  }

}

  

// Only change code above this line

console.log(lookUpProfile("Harry", "lastName"));

```

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [July 21, 2020, 1:47am UTC](https://forum.freecodecamp.org/t/partial-working-contacts-task/410844/2 "2020-07-21T01:47:14Z")

</div>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](http://www.freecodecamp.com/forum/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 12:41pm UTC](https://forum.freecodecamp.org/t/partial-working-contacts-task/410844/3 "2021-06-01T12:41:46Z")

</div>

Closed on June 1, 2021, 12:41pm UTC


