# Record collection - tests not succeeding

**URL:** <https://forum.freecodecamp.org/t/record-collection-tests-not-succeeding/444151>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [February 3, 2021, 11:44am UTC](https://forum.freecodecamp.org/t/record-collection-tests-not-succeeding/444151 "2021-02-03T11:44:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wannesdg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/wannesdg/32/188240_2.png) [@wannesdg](https://forum.freecodecamp.org/u/wannesdg)\
**Post date:** [February 3, 2021, 11:44am UTC](https://forum.freecodecamp.org/t/record-collection-tests-not-succeeding/444151/1 "2021-02-03T11:44:58Z")

</div>

**Tell us what’s happening:**  
Hi,

When testing my code I only get a checkmark for the 4th and 5th test.

 ![tests](https://global.discourse-cdn.com/freecodecamp/original/3X/5/2/52f4019631135fd6eddc3ed18667bd3d3a54cc3f.png)

However, when I test my code with `console.log` everything seems to be working as it should. For example the first test gives this as output:

```auto
id: 5439
prop: artist
value: ABBA
object[id][prop]: undefined
original input:
{ albumTitle: 'ABBA Gold' }
 
conditional executed: 
1
 
result: 
{ albumTitle: 'ABBA Gold', artist: 'ABBA' }

```

As I see it, this should check off the first test.

**Can anyone pitch in what i did wrong here?**

Note: I left the `console.log` code in to see my testing method as well.

Thanks  
Wannes

**Your code so far**

```js

// Setup
var collection = {
2548: {
  albumTitle: 'Slippery When Wet',
  artist: 'Bon Jovi',
  tracks: ['Let It Rock', 'You Give Love a Bad Name']
},
2468: {
  albumTitle: '1999',
  artist: 'Prince',
  tracks: ['1999', 'Little Red Corvette']
},
1245: {
  artist: 'Robert Palmer',
  tracks: []
},
5439: {
  albumTitle: 'ABBA Gold'
}
};

// Only change code below this line
function updateRecords(object, id, prop, value) { 

console.log('id: ' + id)
console.log('prop: ' + prop)
console.log('value: ' + value)
console.log('object[id][prop]: ' + object[id][prop])
console.log('original input:')
console.log(object[id])

console.log(" ")
console.log("conditional executed: ")

if (prop !== 'tracks' && value) {
    console.log("1")  
    collection[id][prop] = value;
  } else if (prop === "tracks" && object[id][prop] == undefined) {
    console.log("2") 
    collection[id][prop] = [value] 
  } else if (prop === "tracks" && value !== "") {
    console.log("3")
    object[id][prop].push(value) 
  } else if (value == "") {
    console.log("4") 
    delete collection[id][prop]
  }

console.log(" ")
console.log("result: ")
console.log(collection[id])
return object;
}

updateRecords(collection, 5439, 'artist', 'ABBA');
//updateRecords(collection, 5439, "tracks", "Take a Chance on Me")
//updateRecords(collection, 2548, "artist", "")
//updateRecords(collection, 1245, "tracks", "Addicted to Love")
//updateRecords(collection, 2468, "tracks", "Free")
//updateRecords(collection, 2548, "tracks", "")
//updateRecords(collection, 1245, "albumTitle", "Riptide")

```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36`.

**Challenge:** Record Collection

**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:** ![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 3, 2021, 12:00pm UTC](https://forum.freecodecamp.org/t/record-collection-tests-not-succeeding/444151/2 "2021-02-03T12:00:45Z")

</div>

how to show the issue…

the tests use a different object than the one in the editor, as said here:

> **Note:** A copy of the `collection` object is used for the tests.

so let’s add a different object, and call the function on that

```auto
const collection2 = {
  1239: {
      'artist': "Abracadabra",
      'year of recording': 2017
   },
   1245: {}
}

updateRecords(collection2, 1239, "title", "Neverwhere")
updateRecords(collection2, 1245, "tracks", "Addicted to Love")

```

add this at the end of your editor, see if what you get with all your console.logs make sense and you understand what’s going on

---

<div class="post-metadata">

**Author:** ![wannesdg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/wannesdg/32/188240_2.png) [@wannesdg](https://forum.freecodecamp.org/u/wannesdg)\
**Post date:** [February 3, 2021, 12:03pm UTC](https://forum.freecodecamp.org/t/record-collection-tests-not-succeeding/444151/3 "2021-02-03T12:03:03Z")

</div>

Thanks for the reply.  
I’ll test this one out and get back to you.

---

<div class="post-metadata">

**Author:** ![wannesdg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/wannesdg/32/188240_2.png) [@wannesdg](https://forum.freecodecamp.org/u/wannesdg)\
**Post date:** [February 3, 2021, 12:13pm UTC](https://forum.freecodecamp.org/t/record-collection-tests-not-succeeding/444151/4 "2021-02-03T12:13:04Z")

</div>

@ILM ,

I figured it out. I was using the name of the object instead of the argument of the function.  
Thanks a lot, stupid that I didn’t see that one myself.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [August 5, 2021, 12:13am UTC](https://forum.freecodecamp.org/t/record-collection-tests-not-succeeding/444151/5 "2021-08-05T00:13:22Z")

</div>

Closed on August 5, 2021, 12:13am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
