function updateRecords(id, prop, value) {
if(prop != "tracks") {
if(value != "") {
collection[id][prop] = value;
}
} else {
if(!collection[id].hasOwnProperty(prop)) {
collection[id][prop] = [];
}
if(value != "") {
collection[id][prop].push(value);
} else {
delete collection[id][prop];
}
}
return collection;
}
The following test won’t pass but I think it should -
After updateRecords(2548, “artist”, “”), artist should not be set
The property isn’t “tracks” so the first if-statement gets executed and then it performs a check if the value is not empty, which it is, so the block shouldn’t get executed and then it should skip the else of the outer if and then return the object (collection) unchanged.
I don’t know what I’m missing.
Link to the exercise - https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/record-collection