# Record Collection -

**URL:** <https://forum.freecodecamp.org/t/record-collection/232948>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [October 10, 2018, 6:31pm UTC](https://forum.freecodecamp.org/t/record-collection/232948 "2018-10-10T18:31:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![brisa](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/brisa/32/159102_2.png) [@brisa](https://forum.freecodecamp.org/u/brisa)\
**Post date:** [October 10, 2018, 6:31pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/1 "2018-10-10T18:31:48Z")

</div>

**Tell us what’s happening:**  
I tested all and they seem to work . I can’t figure out why I keep getting the auto tests wrong and not being able to pass.

**Your code so far**

```js

// 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" && value !== "") {
        collection[id].album = value;
    }
    if (prop == "tracks" && collection[id].hasOwnProperty("tracks") === false) {
        collection[id].tracks = [];
    }
    if (prop == "tracks" && value !== "") {
        collection[id].tracks.push(value);
    }
    if (prop === "artist") {
        collection[id].artist = value;
    }
    if (prop === "album") {
        collection[id].album;
    }

    if (value === "") {
        delete collection[id].prop;
    }

    return collection[id];
}

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

```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36`.

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/record-collection)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![ArielLeslie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arielleslie/32/264841_2.png) [@ArielLeslie](https://forum.freecodecamp.org/u/ArielLeslie)\
**Post date:** [October 10, 2018, 6:51pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/2 "2018-10-10T18:51:41Z")

</div>

What do the failing tests say?

---

<div class="post-metadata">

**Author:** ![ArielLeslie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arielleslie/32/264841_2.png) [@ArielLeslie](https://forum.freecodecamp.org/u/ArielLeslie)\
**Post date:** [October 10, 2018, 6:54pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/3 "2018-10-10T18:54:38Z")

</div>

Read the instructions carefully:

> Your function must always return the entire collection object.

---

<div class="post-metadata">

**Author:** ![brisa](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/brisa/32/159102_2.png) [@brisa](https://forum.freecodecamp.org/u/brisa)\
**Post date:** [October 10, 2018, 7:02pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/4 "2018-10-10T19:02:45Z")

</div>

Thank you! I changed the return statement to `return collection;`, however, I still get errors, where locally tests pass

 ![27%20AM](https://global.discourse-cdn.com/freecodecamp/original/3X/5/6/566ece8651e6a01bd430d2c0a03ad9a9bc927e0b.png)

---

<div class="post-metadata">

**Author:** ![ArielLeslie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arielleslie/32/264841_2.png) [@ArielLeslie](https://forum.freecodecamp.org/u/ArielLeslie)\
**Post date:** [October 10, 2018, 7:03pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/5 "2018-10-10T19:03:25Z")

</div>

Looks like you’re not correctly handling the case where the last parameter is an empty string.

---

<div class="post-metadata">

**Author:** ![brisa](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/brisa/32/159102_2.png) [@brisa](https://forum.freecodecamp.org/u/brisa)\
**Post date:** [October 10, 2018, 7:07pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/6 "2018-10-10T19:07:13Z")

</div>

But it looks correct here… (thank you so much for helping!)

 ![21%20PM](https://global.discourse-cdn.com/freecodecamp/original/3X/8/0/80e07ad4d859b9ab7cfd5406e28545aab2c5a15c.png)

---

<div class="post-metadata">

**Author:** ![ArielLeslie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arielleslie/32/264841_2.png) [@ArielLeslie](https://forum.freecodecamp.org/u/ArielLeslie)\
**Post date:** [October 10, 2018, 7:30pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/7 "2018-10-10T19:30:50Z")

</div>

Again, read the instructions carefully.

> If `value` is empty ( `""` ), delete the given `prop` property from the album.

---

<div class="post-metadata">

**Author:** ![brisa](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/brisa/32/159102_2.png) [@brisa](https://forum.freecodecamp.org/u/brisa)\
**Post date:** [October 10, 2018, 7:52pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/8 "2018-10-10T19:52:16Z")

</div>

Thank you!! For a reason that I don’t understand `delete collection[id][prop];` worked but `delete collection[id].prop;` did not.

It’s not the first time I see the bracket notation working and the dot notation failing. Is there a place where I can read more?

It all worked now:)

---

<div class="post-metadata">

**Author:** ![ArielLeslie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arielleslie/32/264841_2.png) [@ArielLeslie](https://forum.freecodecamp.org/u/ArielLeslie)\
**Post date:** [October 10, 2018, 7:57pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/9 "2018-10-10T19:57:51Z")

</div>

Rembember that dot notation and bracket notation are different things and they work differently. You can go back to the challenges that introduced them in FCC. (Hint: if you do a search here in the forum, you can include @arielleslie to the search term and find several places where I have gone into detail about this.)

---

<div class="post-metadata">

**Author:** ![brisa](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/brisa/32/159102_2.png) [@brisa](https://forum.freecodecamp.org/u/brisa)\
**Post date:** [October 10, 2018, 8:07pm UTC](https://forum.freecodecamp.org/t/record-collection/232948/10 "2018-10-10T20:07:23Z")

</div>

Yes, I remember. I think I didn’t understand completely before, otherwise, I could have saved us a lot of time:) Awesome! Thank yoU!

---

<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:** [February 2, 2021, 11:27am UTC](https://forum.freecodecamp.org/t/record-collection/232948/11 "2021-02-02T11:27:49Z")

</div>

Closed on February 2, 2021, 11:27am UTC


