Hello, I’ve written this bit of code and can’t figure out why it isn’t working properly:
function updateRecords(id, prop, value) {
if (value == "") {
delete collection[id][prop];
}
else {
if (prop = "tracks") {
if (collection[id].hasOwnProperty("tracks") == false) {
collection[id][prop] = new Array();
collection[id][prop].push(value);
} else {
collection[id][prop].push(value);
}
} else {
collection[id][prop] = value;
}
}
return collection;
In particular the last line collection[id][prop] = value
it’s working just fine in isolation but not inside this setup.
Can anybody tell me why this is?
Thank you.