Hi there, I started with javascript a while ago, and am now going back to the start of the course to refresh everything, and I’m finding myself having trouble with the record collection task. This is the error message I’m getting and below is the function (not the setup). Thanks in advance!
Error Message
Cannot read property '5439' of undefined
Cannot read property '5439' of undefined
Cannot read property '1245' of undefined
Cannot read property '2468' of undefined
Cannot read property '1245' of undefined
My Solution
function updateRecords(id, prop, value) {
if (value === "") {
delete collection[id][prop];
}
else if (prop === "tracks") {
if (collection[id][prop]) {
collection[id][prop].push(value)
} else
collection[id][prop]=[value];
}
else if (prop != "tracks") {
collection[id][prop] = value;
}
else {
return "You didn't use the function correctly!";
}
}
