I dont understand why there is a second if after if (prop === “tracks” && value !== “”). Do you need that second if? I thought you could just execute the piece of code straight after the first if statement was satisfied? I have tried removing it and played around with it a bit but cant get it to work.
function updateRecords(id, prop, value) {
if (prop === "tracks" && value !== "") {
if(collection[id][prop]) {
collection[id][prop].push(value);
}
else {
collection[id][prop]=[value];
}
} else if (value !== "") {
collection[id][prop] = value;
} else {
delete collection[id][prop];
}
return collection;
}