# Record Collection, Why my code doesn't passed?

**URL:** <https://forum.freecodecamp.org/t/record-collection-why-my-code-doesnt-passed/35084>\
**Category:** General\
**Created:** [September 8, 2016, 11:52am UTC](https://forum.freecodecamp.org/t/record-collection-why-my-code-doesnt-passed/35084 "2016-09-08T11:52:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![toperkemur](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/toperkemur/32/14903_2.png) [@toperkemur](https://forum.freecodecamp.org/u/toperkemur)\
**Post date:** [September 8, 2016, 11:52am UTC](https://forum.freecodecamp.org/t/record-collection-why-my-code-doesnt-passed/35084/1 "2016-09-08T11:52:52Z")

</div>

Hi, i’m currently on challenge 211 : Record Collection Challenge.

**After updateRecords(2468, “tracks”, “Free”), tracks should have “1999” as the first element.**  
This is the only condition that i failed.

i confused because i managed to fulfill the condition and still failed.  
collection =  
{  
“1245”: {  
“artist”: “Robert Palmer”,  
“tracks”: []  
},  
“2468”: {  
“album”: “1999”,  
“artist”: “Prince”,  
“tracks”: [  
“1999”,  
“Little Red Corvette”  
]  
},  
“2548”: {  
“album”: “Slippery When Wet”,  
“artist”: “Bon Jovi”,  
“tracks”: [  
“Let It Rock”,  
“You Give Love a Bad Name”  
]  
},  
“5439”: {  
“album”: “ABBA Gold”,  
“artist”: “ABBA”  
}  
}

**And this is my code:**  
function updateRecords(id, prop, value) {  
if(value === “”){

```
    delete collection[id][prop];
    
  }else {
    if(prop === "tracks"){
      
      if(!collection.hasOwnProperty("tracks")){
        collection[id][prop] = [];
        collection[id][prop].push(value);
      }
        
      else {
        collection[id][prop].push(value); 
      }
      
    }else {
      collection[id][prop] = value;
    }
    
    
  }
  
  return collection;
}

```

Anyone can help me with this?

thank you really appreaciate it

---

<div class="post-metadata">

**Author:** ![kevcomedia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevcomedia/32/125737_2.png) [@kevcomedia](https://forum.freecodecamp.org/u/kevcomedia)\
**Post date:** [September 8, 2016, 12:27pm UTC](https://forum.freecodecamp.org/t/record-collection-why-my-code-doesnt-passed/35084/2 "2016-09-08T12:27:43Z")

</div>

Which object are you calling `hasOwnProperty` with?

---

<div class="post-metadata">

**Author:** ![toperkemur](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/toperkemur/32/14903_2.png) [@toperkemur](https://forum.freecodecamp.org/u/toperkemur)\
**Post date:** [September 8, 2016, 4:04pm UTC](https://forum.freecodecamp.org/t/record-collection-why-my-code-doesnt-passed/35084/3 "2016-09-08T16:04:17Z")

</div>

Hi @kevcomedia!!

Thank you, your question made me realize that i forgot to put the id on that line!! really appreaciate it.

I’m using hasOwnProperty to test if the object i called has a “tracks” key. But your question make me realize that i only called an object without specified any key.

silly me. It’s been 2 days i’m stuck with this challenge

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 5:29am UTC](https://forum.freecodecamp.org/t/record-collection-why-my-code-doesnt-passed/35084/4 "2021-01-16T05:29:30Z")

</div>

Closed on January 16, 2021, 5:29am UTC


