Last active
February 15, 2018 23:26
-
-
Save aaronranard/c82582b47dc6cd4a2a2ed8d956126c2c to your computer and use it in GitHub Desktop.
Revisions
-
aaronranard revised this gist
Feb 15, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -15,5 +15,5 @@ const backToKeyValueObj = keyValueArray.reduce((obj, { key, value }) => ({ ...ob /** * backToKeyValueObj: * { "api_url": "https://hawaii.usa.gov", "message": "BALLISTIC MISSILE INBOUND.", "is_drill": true } */ -
aaronranard revised this gist
Feb 15, 2018 . 1 changed file with 19 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,19 @@ const keyValueObj = { "api_url": "https://hawaii.usa.gov", "message": "BALLISTIC MISSILE INBOUND.", "is_drill": true }; const keyValueArray = Object.entries(keyValueObj).map(([key, value]) => ({ key, value })); /** * keyValueArray: * [ * { key: "api_url", value: "https://hawaii.usa.gov" }, * { key: "message", value: "BALLISTIC MISSILE INBOUND." }, * { key: "is_drill", value: true }, * ], * */ const backToKeyValueObj = keyValueArray.reduce((obj, { key, value }) => ({ ...obj, [key]: value}), {}) /** * backToKeyValueObj: * { "api_url": "https://hawaii.usa.gov", "message": "BALLISTIC MISSILE INBOUND. THIS IS NOT A DRILL.", "is_drill": true } */ -
aaronranard created this gist
Feb 15, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ const keyValueObj = { "key": "value", "key2": "value2", "key3": "value3" }; const keyValueArray = Object.entries(keyValueObj).map(([key, value]) => ({ key, value }));