Skip to content

Instantly share code, notes, and snippets.

@michael-mafi
Last active January 9, 2017 00:21
Show Gist options
  • Select an option

  • Save michael-mafi/e95c4fcd5802f8f74e8d777210a62fdb to your computer and use it in GitHub Desktop.

Select an option

Save michael-mafi/e95c4fcd5802f8f74e8d777210a62fdb to your computer and use it in GitHub Desktop.
//use a var arr = [[[]]]; //////// also side note: don't forget Object.keys() Object.values() and Object.entries()
function transformData(arr){
var output = {};
array.forEach(function(item, index){
if(!item)return;
if(Array.isArray(item)){
output[index] = transformData(item);
}else{
output[index] = item;
}
});
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment