Record collection


i need to if the problem in my logic condition or how i access the object ?

Sir, can you provide us with your code instead of a screenshot? The photo is leaving out a part of your code. Also, it’s easier to work with your code.

1 Like
// 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 (records[id][value] === ""){
     delete records[id][prop]
  } else if(records[id][prop] !== records[id][value] && records[id][value] === "") {
    records[id][value] = records[id][prop]
  } else if (records[id][prop] === records[id][value] && records[id][value]){
    if (records[id][value] === false){
      records[id][value] = []
      records[id][value].push(value)
    }

  }
  return records;
}

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

Hello @abdu_abudrais !

You may wish to take a look at this great guidance from Jessica Wilkens on How to solve the Record Collection.

I found the article in freeCodeCamp News.

Happy coding! :sun_with_face:

1 Like

What’s this line doing? I suspect it’s more complicated than you need.

You still want to push when the records array is present. Also, that if statement doesn’t check if the array is present, it checks if the array is the Boolean literal ‘false’, which it cannot be.

1 Like

thank you for guiding me

1 Like

Hi Guys, this took my three days, and also thanks to Jessica Wilkins for the linked post it has given me big help: so here is the solution 100% solve:

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

Thanks for clarifying, I was having doubts of doing the whole posting, since its my first day of posting, I did not know better. Thanks once again.

1 Like