# FREECODECAMP -\>ADVANCE ALGORITHM SCRIPTING-\>Record Collection bug? \[SOLVED\]

**URL:** <https://forum.freecodecamp.org/t/freecodecamp-advance-algorithm-scripting-record-collection-bug-solved/113731>\
**Category:** General\
**Created:** [May 9, 2017, 9:01am UTC](https://forum.freecodecamp.org/t/freecodecamp-advance-algorithm-scripting-record-collection-bug-solved/113731 "2017-05-09T09:01:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![1LifeLess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/1lifeless/32/51518_2.png) [@1LifeLess](https://forum.freecodecamp.org/u/1LifeLess)\
**Post date:** [May 9, 2017, 9:01am UTC](https://forum.freecodecamp.org/t/freecodecamp-advance-algorithm-scripting-record-collection-bug-solved/113731/1 "2017-05-09T09:01:16Z")

</div>

as you can see in the image, i added “FREE” to “Tracks” array, and “1999” is the first element at the same array, so i don’t understand the error it gives me

 ![](https://global.discourse-cdn.com/freecodecamp/original/3X/9/f/9f5015a127fe25b68cb15a88297b186d8b65c410.png)

---

<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:** [May 9, 2017, 9:05am UTC](https://forum.freecodecamp.org/t/freecodecamp-advance-algorithm-scripting-record-collection-bug-solved/113731/2 "2017-05-09T09:05:04Z")

</div>

Can you post your code (not a screenshot, but the code itself)? 🙂

---

<div class="post-metadata">

**Author:** ![1LifeLess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/1lifeless/32/51518_2.png) [@1LifeLess](https://forum.freecodecamp.org/u/1LifeLess)\
**Post date:** [May 9, 2017, 9:14am UTC](https://forum.freecodecamp.org/t/freecodecamp-advance-algorithm-scripting-record-collection-bug-solved/113731/3 "2017-05-09T09:14:48Z")

</div>

```
          // 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
// Only change code below this line
 function updateRecords(id, prop, value) {
 console.log(Boolean(value));
 if (prop=="tracks"&& Boolean(value)===true){
 var property = collection[id][prop];
 if(Array.isArray(property)) property.push(value);
else {property=[];property.push(value);}
}
else if(!Boolean(value)){
delete collection[id][prop];
 }
  else{
  collection[id][prop]=value;
 }
return collection;
 }
// Alter values below to test your code
 updateRecords(2468, "tracks", "Free");`Preformatted text`
```

---

<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:** [May 9, 2017, 9:26am UTC](https://forum.freecodecamp.org/t/freecodecamp-advance-algorithm-scripting-record-collection-bug-solved/113731/4 "2017-05-09T09:26:21Z")

</div>

Hmmm… I’m getting different tests wrong. I got the first two tests wrong, and the test in question is green.

![](https://global.discourse-cdn.com/freecodecamp/original/3X/d/3/d3631ec012f9230522f7dd8edc43c20fe2d29592.png)

I noticed that this line is missing in your code (right before the function declaration):

```javascript
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

```

When I added it back the first test went green.

---

<div class="post-metadata">

**Author:** ![1LifeLess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/1lifeless/32/51518_2.png) [@1LifeLess](https://forum.freecodecamp.org/u/1LifeLess)\
**Post date:** [May 9, 2017, 9:38am UTC](https://forum.freecodecamp.org/t/freecodecamp-advance-algorithm-scripting-record-collection-bug-solved/113731/5 "2017-05-09T09:38:21Z")

</div>

well, u were right’ for some reason it was stuck on that error for no reason, i had to remove something in the code for the error to update :-/, solved it, thanks

---

<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:56pm UTC](https://forum.freecodecamp.org/t/freecodecamp-advance-algorithm-scripting-record-collection-bug-solved/113731/6 "2021-01-17T20:56:49Z")

</div>

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


