function updateRecords(records, id, prop, value) {
const a = records[id].hasOwnProperty(prop);
if(value === ""){
delete records[id].prop;
}else if(prop === "tracks" && a === false
){
records[id].prop=[value];
}else if(prop === "tracks" && a === true) {
records[id].prop.push(value);
}else if(prop !== "tracks"){
records[id].prop=value;
}
return records;
}
updateRecords(recordCollection, 5439, 'artist', 'ABBA');
You can’t use dots here. You are dealing with variables, brackets needed
1 Like
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.