I need help with Record Collection

Tell us what’s happening:
I think this should work but it wont get any tests right any solutions

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(object, id, prop, value) {
collection[id][prop] = value;
return value;

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

Your browser information:

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

Challenge: Record Collection

Link to the challenge:

Hey There,

I think you are just changing the id value in the above code

function updateRecords(object, id, prop, value) {
  if (value === '') delete object[id][prop];
  else if (prop === 'tracks') {
    object[id][prop] = object[id][prop] || []; // this is called shortcircuit evaluation, see below for explanation
  } else {
    object[id][prop] = value;

  return object;

I think this should work.

1 Like

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

Hi @NoneCoder
It seems like your code does not satisfy the given conditions in the challenge. It’s like just changing property values.
So you need to write your code to fulfil the given conditions.

Try to undrestand the logic with the given conditions :grinning:

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

  // first condition
  if(value != "" && prop != "tracks"){  

  // second condition
  }else if(prop == "tracks" && !object[id].hasOwnProperty("tracks")){
    // you have to create an array to store tracks.
    //  object[id][prop] = [] is an array, with the given property ( tracks )
    // Now, try to insert the value that given as function's parameter, as the value 
   //  of this array

  // third condition
  }else if(prop == "tracks" && value != ""){

  // forth condition
  }else if(value == ""){

  return object;

Thank you for your kind guidance.
I will try to implement the above instructions from now on .