Tell us what’s happening:
Describe your issue in detail here.
**Your 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) {
//delete records
if (value == "") {
console.log(prop + " is blank. The " + prop +" property is being deleting!");
delete recordCollection[id][prop];
return records;
} else if
// not tracks
(prop != "tracks") {
console.log(value + " is being added as " + prop +" for entry " + id +"!");
recordCollection[id][prop] = value;
return records;
} else if
// tracks but no tracks yet
(prop == "tracks" && recordCollection[id].hasOwnProperty("tracks") == false) {
console.log("The tracks property is being added!");
recordCollection[id][prop] = "tracks";
recordCollection[id][prop] = [];
console.log("The track is being added!");
recordCollection[id][prop].push(value)
return records;
} else if
// tracks but no tracks yet
(prop == "tracks" && recordCollection[id].hasOwnProperty("tracks") == true) {
console.log("The track is being added!");
recordCollection[id][prop].push(value)
return records;
}
return records;
}
updateRecords(recordCollection, 5439, 'artist', 'ABBA');
updateRecords(recordCollection, 5439, 'tracks', 'Take A Chance On Me');
updateRecords(recordCollection, 2548, "artist", "");
updateRecords(recordCollection, 1245, "tracks", "Addicted to Love");
updateRecords(recordCollection, 2468, "tracks", "Free");
updateRecords(recordCollection, 2548, "tracks", "");
updateRecords(recordCollection, 1245, "albumTitle", "Riptide");
//updateRecords(recordCollection, 5439, 'tracks', 'Dancing Queen');
//console.log(recordCollection);
//updateRecords(recordCollection, 5439, 'albumTitle', '');
console.log(recordCollection);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36
Challenge: Record Collection
Link to the challenge: