Skip to content

Instantly share code, notes, and snippets.

@BenFausch
Created March 9, 2018 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenFausch/993f2db7f1b657db6f1165f616d3f40a to your computer and use it in GitHub Desktop.
Save BenFausch/993f2db7f1b657db6f1165f616d3f40a to your computer and use it in GitHub Desktop.
user an array of key names to verify that they're in an object, add empty array with key 0 if false
var checker = ['attain-location-address-1', 'attain-location-address-2', 'attain-location-city', 'attain-location-state', 'attain-location-zipcode']
for (var i = 0; i < checker.length; i++) {
if (!result['custom_fields'].hasOwnProperty(checker[i])) {
result['custom_fields'][checker[i]] = [];
result['custom_fields'][checker[i]][0] = '';
}
}
return result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment