Last active
March 28, 2018 16:36
-
-
Save luislobo14rap/07ae57f5e63f96e21a217c93184de143 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //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