Last active
August 22, 2016 04:52
-
-
Save piq9117/178042c5e9ab5017f40b9b0ca616f1e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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