Record Collection__

I can’t get my code to work

I copied to solution in the comments I made, but I don’t understand why mines can’t work. Specifically my 3rd and 4th else if statements aren’t working.

  **My 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 !== "") {
  records[id][prop] = value;
}
else if(prop === "tracks" && !records.hasOwnProperty("tracks")) {
  records[id][prop] = [value];
}
else if(prop === "tracks" && value !== "") {
  records[id][prop].push(value); //records[id][prop].push(value);
}
else {
delete records[id][prop];
}
// if (prop !== 'tracks' && value !== "") {
//     records[id][prop] = value;
//   } else if (prop === "tracks" && records[id].hasOwnProperty("tracks") === false) {
//     records[id][prop] = [value];
//   } else if (prop === "tracks" && value !== "") {
//     records[id][prop].push(value);
//   } else if (value === "") {
//     delete records[id][prop];
//   }
return records;
}
//updateRecords(recordCollection, 5439, 'artist', 'ABBA');
updateRecords(recordCollection, 2468, "tracks", "Free")
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15

Challenge: Record Collection

Link to the challenge:

HI @clojr12 !

Welcome to the forum!

You are missing something here.

Once you fix that then the test will pass.

Hope that helps!

Thanks I see my mistake and corrected it. Thank you so much. :+1: