# \[SOLVED\] Record Collection Error

**URL:** <https://forum.freecodecamp.org/t/solved-record-collection-error/155892>\
**Category:** General\
**Created:** [October 29, 2017, 9:46pm UTC](https://forum.freecodecamp.org/t/solved-record-collection-error/155892 "2017-10-29T21:46:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erdal](https://avatars.discourse-cdn.com/v4/letter/e/848f3c/32.png) [@erdal](https://forum.freecodecamp.org/u/erdal)\
**Post date:** [October 29, 2017, 9:46pm UTC](https://forum.freecodecamp.org/t/solved-record-collection-error/155892/1 "2017-10-29T21:46:06Z")

</div>

**Tell us what’s happening:**

**Your code so far**

```auto
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": []
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  
  if(prop==="tracks"){
    
    if(!collection[id].hasOwnProperty(prop)){
      collection[id][prop]=[];
      collection[id][prop].push(value);
    }
    else if(collection[id].hasOwnProperty(prop) ){
      if(value!==""){
         collection[id][prop].push(value);
      }
      else {
        delete collection[id][prop];
      }
    }
  }
  else if(prop!=="tracks" && value!==""){
    
      collection[id][prop]=value;
    
  }
 
  
  return collection;
}

// Alter values below to test your code
updateRecords(2548, "artist", "");

```

Hey, I’m having a problem with this challenge.It fails the .updateRecords(2548, “artist”, “”); which says it shouldn’t be added but by code isn’t updating the artist property to " ". It still is “Bon Jovi”. Any help will be appreciated thanks 🙂 . [Solved]

---

<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:** [October 30, 2017, 12:14am UTC](https://forum.freecodecamp.org/t/solved-record-collection-error/155892/2 "2017-10-30T00:14:39Z")

</div>

~~You forgot to check if `prop !== 'tracks' && value === ''`~~

I didn’t see the little `[Solved]` at the end of your post 😅

---

<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:** [January 17, 2021, 8:35pm UTC](https://forum.freecodecamp.org/t/solved-record-collection-error/155892/3 "2021-01-17T20:35:59Z")

</div>

Closed on January 17, 2021, 8:35pm UTC


