Record Collection 2548

Tell us what’s happening:
Describe your issue in detail here.

Hey all,
Like so many others, I’m stuck on this Record Collection-lesson. I get two persistent error messages:

after updaterecords(recordcollection, 2548, “artist”, “”), artist should not be set
after updaterecords(recordcollection, 2548, “tracks”, “”), tracks should not be set

I printed recordCollection to the console and both “artist” and “tracks” are being removed/deleted - I just keep getting the error message. I have compared the code to other people’s code I’ve found online, and it’s identical from what I can see. I even copied other answers, and I still end up with the exact same error message.

Could anyone please point me in the right direction?
Thank you!


  **Your code so far**

// Setup
const recordCollection = {
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(records, id, prop, value) {
if (prop !== 'tracks' && value !== '') {
  recordCollection[id][prop] = value;
} else if (prop === "tracks" && recordCollection[id].hasOwnProperty("tracks") === false) {
  recordCollection[id][prop] = [value];
} else if (prop === "tracks" && value !== "") {
} else if (value === "") {
  delete recordCollection[id][prop];
return recordCollection;

updateRecords(recordCollection, 5439, 'artist', 'ABBA');

  **Your browser information:**

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

Challenge: Record Collection

Link to the challenge:

Hello and Welcome!

Double-check the names of your parameters versus what variable you are referring to in your if statements and return value.

Hope this helps!

You should never directly reference this variable.

I’m not sure I understand - How can I do anything with a variable if I can’t reference it?
Would not referencing the variable allow my code to pass the challenge?
What would code without referencing the variable look like?
Sorry for the very basic questions, I’m literally on my first week of JS, haha.

Does it have anything to do with the “records” parameter in the function parenthesis?
I don’t see it declared anywhere else, but I also don’t know what other parameter to use to for recordCollection. Other than that, I can’t see any differences between the names of parameters and those in the if-statements, besides mixing ’ and ", but that should not be an issue here, right?

1 Like

Actually, I changed “records” to “recordCollection” and it passed. So I guess you solved it haha. Thank you!

1 Like

Yup, you need to use tme function argument instead of the global variable.

I assume you mean recordCollection to records, but yes exactly! You are passing in recordCollection as the parameter records, which is how it should be referred to inside of the function. This is why JeremyLT was saying not to directly reference the variable.

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