Tell us what’s happening:
Hello. I pass all tests except for 3, it is failing because its giving the property “tracks” a duplicate value.
Your code so far
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'
}
};
const updateRecords = (records, id, prop, value) => {
if (value == "") {
delete records[id][prop];
};
if (prop != "tracks" && value != "") {
records[id][prop] = [value];
};
if (prop == "tracks" && value != "" && !records[id].hasOwnProperty("tracks")) {
records[id][prop] = [];
records[id][prop].push(value);
};
if (prop == "tracks" && value != "" && records[id].hasOwnProperty("tracks")) {
records[id][prop].push(value);
};
return records;
};
// console.log(updateRecords(recordCollection, 5439, "artist", "ABBA"));
// console.log(updateRecords(recordCollection, 5439, "tracks", "Take a Chance on Me"));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:151.0) Gecko/20100101 Firefox/151.0
Challenge Information:
Build a Record Collection - Build a Record Collection