Skip to content

Instantly share code, notes, and snippets.

@luislobo14rap
Last active March 28, 2018 16:36
Show Gist options
  • Select an option

  • Save luislobo14rap/07ae57f5e63f96e21a217c93184de143 to your computer and use it in GitHub Desktop.

Select an option

Save luislobo14rap/07ae57f5e63f96e21a217c93184de143 to your computer and use it in GitHub Desktop.
//input: jsonToArray({a: 1, b: 2 , c: 3});
//output: [ ['a', 'b', 'c'], [1, 2, 3] ];
function jsonToArray(obj){
let returnArray = [];
let key = [];
let values = [];
for( let thisKey in obj ){
//console.log( thisKey + ': ' + obj[thisKey] );
key.push( thisKey );
values.push( obj[thisKey] );
};
returnArray.push(key, values);
return returnArray;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment