Skip to content

Instantly share code, notes, and snippets.

@piq9117
Last active August 22, 2016 04:52
Show Gist options
  • Save piq9117/178042c5e9ab5017f40b9b0ca616f1e0 to your computer and use it in GitHub Desktop.
Save piq9117/178042c5e9ab5017f40b9b0ca616f1e0 to your computer and use it in GitHub Desktop.
function updateRecords (id, prop, value) {
if (prop === 'artist') {
collection[id][prop] = value
if (value === '') {
delete collection[id][prop]
}
}
else if (prop === 'tracks') {
if (!collection[id]['tracks']) {
collection[id][prop] = new Array(value)
}
else if (collection[id]['tracks'].length === 0) {
collection[id]['tracks'].push(value)
}
else if (value === '') {
delete collection[id]['tracks']
}
}
return collection;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment