Tell us what’s happening:
Describe your issue in detail here.
Hey all,
Like so many others, I’m stuck on this Record Collection-lesson. I get two persistent error messages:
after updaterecords(recordcollection, 2548, “artist”, “”), artist should not be set
after updaterecords(recordcollection, 2548, “tracks”, “”), tracks should not be set
I printed recordCollection to the console and both “artist” and “tracks” are being removed/deleted - I just keep getting the error message. I have compared the code to other people’s code I’ve found online, and it’s identical from what I can see. I even copied other answers, and I still end up with the exact same error message.
Could anyone please point me in the right direction?
Thank you!
/Kris
**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) {
if (prop !== 'tracks' && value !== '') {
recordCollection[id][prop] = value;
} else if (prop === "tracks" && recordCollection[id].hasOwnProperty("tracks") === false) {
recordCollection[id][prop] = [value];
} else if (prop === "tracks" && value !== "") {
recordCollection[id][prop].push(value);
} else if (value === "") {
delete recordCollection[id][prop];
}
return recordCollection;
}
updateRecords(recordCollection, 5439, 'artist', 'ABBA');
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36
Challenge: Record Collection
Link to the challenge: