I struggled to get a solution to Record Collection but (after having a quick peek at the hints) get something which runs in my browser console and seems to make all the required changes to the record collection.
When I ‘Run the Tests’ I get an error:
updateRecords(...)[5439].tracks.pop is not a function
I do not even use .pop in my code so this is confusing me.
My solution to the problem is to change the updateRecords() function to the the following:
function updateRecords(id, prop, value) {
if (prop === "tracks") {
if (collection[id][prop]) {
if (value !="") {
collection[id][prop].push(value);
} else {
delete collection[id][prop]
}
} else {
collection[id][prop] = value;
}
}
if (prop === "artist" && value != "") {
collection[id][prop] = value;
}
if (prop === "artist" && value ==="") {
delete collection[id][prop];
}
if (prop === "album") {
collection[id][prop] = value;
}
return collection;
}
I would really appreciate knowing what is going on.