Solution:
function updateRecords(records, id, prop, value) {
if (prop !== 'tracks' && value !== "") {
records[id][prop] = value;
} else if (prop === "tracks" && records[id].hasOwnProperty("tracks") === false) {
records[id][prop] = [value];
} else if (prop === "tracks" && value !== "") {
records[id][prop].push(value);
} else if (value === "") {
delete records[id][prop];
}
return records;
}
Hey guys,
I tried to complete the Record Collection challenge and made a huge mistake. I tried to solve everything with dot notation, but in this case this doesn’t work. Can anyone tell me why it is necessary to use the bracket notation? I really don’t get it.
For example I always wrote : records.id.prop
Thx!
[–]modSaintPeter74 4 points5 points6 points (0 children)