Need help with the solution of Record Collection

Tell us what’s happening:

Your code so far


// 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(id, prop, value) {
if (value === "") {
  delete collection[id][prop];
} else if (prop === "tracks") {
collection[id][prop] = collection[id][prop] || [];
collection[id][prop].push(value);
} else {
  collection[id][prop] = value;
}

return collection;
}

//Alter values below to test your code
updateRecords(2468, "tracks", "test");
console.log(updateRecords(5439, "artist", "ABBA"));

Your browser information:

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

Challenge: Record Collection

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

The more information you give us, the more likely we are to be able to help.

Everything is fine except u have to look it again one more time in function argument

I already posted my comment, but still doesn`t work. Need help find what is wrong with my solution.

U are missing one argument and that arguments should be used in your code not var collection
like u need to make paramenter in function to define collection as object like which object this function is taking as parameter.
Hope so u understood

Could you please show me which argument?

u neeed to pass object in function parameter just like u passed id prop and value

function updatedRecords(object,id,prop,value) {
}
console.log(updatedRecords(collection,5439,"artist","ABBA"));

like this
and use that parameter in ur function code

function updateRecords(object,id, prop, value) {

console.log(updateRecords(collection,5439,“artist”,“ABBA”));

if (value === “”)

Like this? Still not working

ur code isnt showing
u need to change the code in ur function too like u have to use passed parameter for object instead of collection

I can`t find it…It is not working.

can u show me your renewed code </> click on this symbol from bar when u are to reply and write ur current code there

oh noooooo i just saw this console.log will be at end i just gave example how u wil u write prameters and will put its value dosent mean that u will write values just after defining prameters

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

// Only change code below this line
function updateRecords(object,id, prop, value) {
  console.log(updateRecords(collection,5439,"artist","ABBA"));
  if (value === "") 
  {
    delete collection[id][prop];
  } 
  else if (prop === "tracks") {
  collection[id][prop] = collection[id][prop] || [];
  collection[id][prop].push(value);
  } else {
    collection[id][prop] = value;
  }

  return collection;
}

//Alter values below to test your code
updateRecords(2468, "tracks", "test");
 object[id][prop] =  object[id][prop] || [];

this what i was talking about that use pramaeter u passed in function in code not collection just like this example replace collection with parameter u passed

You didn’t fill out Tell, us what’s happening or describe your issue, which is why I asked.

It looks like you copied an old solution (possibly from the video?) and changed the function signature. You should not reference the global variable collection at all in your code.

Yes I tried to understand what I was doing wrong and correct. I still can not find the correct solution. I watched the tutorials and forums but I still can`t find.

everywhere in your function where you have collection, you should not. You need to use the object passed in as an argument in the original function signature.

console.log(updateRecords(collection,5439,"artist","ABBA"));

i was just giving u example how to use after passing parameter object in function ,not to changing its position u define its parameter outside function not within curly braces of function.