Last active
May 15, 2020 16:49
-
-
Save bobdobbalina/119d829982c87adaa524ad21e0036f8a to your computer and use it in GitHub Desktop.
Arrays
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
{ | |
"scripts": [], | |
"showConsole": true, | |
"template": true | |
} |
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
const prefs = [ | |
{ | |
"Type": "TestType1", | |
"Key": "key4", | |
"Value": { | |
"key": "updated value" | |
} | |
}, | |
{ | |
"Type": "FleetOrder", | |
"Key": "FleetOrder", | |
"Value": { | |
"FleetOrder": [ | |
32, | |
93, | |
31, | |
333, | |
2444, | |
2575 | |
] | |
} | |
}, | |
{ | |
"Type": "TestType1", | |
"Key": "key3", | |
"Value": { | |
"key": "updated value" | |
} | |
}, | |
{ | |
"Type": "TestType1", | |
"Key": "key1", | |
"Value": { | |
"key": "Test a new value" | |
} | |
} | |
] | |
const testTypeObject = prefs.filter( x => x.Type === 'TestType1' ); | |
const testType = testTypeObject[0].Value; | |
const fleetOrderObject = prefs.filter( x => x.Value.FleetOrder ); | |
const fleetOrder = fleetOrderObject[0].Value; | |
const userPrefs = { ...fleetOrder, ...testType }; | |
console.dir( JSON.stringify(userPrefs) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment