Record Collection code review

What’s wrong with my code?

// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "Little Red Corvette" 
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    "5439": {
      "album": "ABBA Gold"
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if (prop === tracks && value !== ""){
    collection[id][prop] = collection[id][prop] || []
  } else {
    delete collection[id][prop]
  return collection;

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

why is there a “tracks”: [ not that it wrong but it seems a bit ooddd

Hello @kabirsumn!

Could you please provide more information on what are you trying to achieve with the code? If it is a challenge in freeCodeCamp, could you name it so we can have more information to try and help you out?

What I can see from your code that seems to be an incorrect syntax is that line:

if (prop === tracks && value !== ""){

Again, I am not sure of your intent, but if it was to compare the received prop to the string tracks, you’d have to use " ", like that:

if (prop === "tracks" && value !== ""){

If you don’t add the " ", Javascript would be looking for a variable named tracks, which does not exist.


Thank you very much!
yes, it’s a code challenge in freeCodeCamp named “Record Collection”