{"ScriptPreparationCode":null,"TestCases":[{"Name":"Using array filter and reduce \u002B spread","Code":"PRIMARY_SCOPES = [\u0027a\u0027, \u0027d\u0027]\r\navailableScopes = {\u0027a\u0027: \u0027A\u0027, \u0027b\u0027: \u0027B\u0027, \u0027c\u0027: \u0027C\u0027, \u0027d\u0027: \u0027D\u0027}\r\n\r\nconst output = PRIMARY_SCOPES.filter((scope) =\u003E scope in availableScopes).reduce(\r\n (result, scope) =\u003E ({\r\n ...result,\r\n [scope]: availableScopes[scope],\r\n }),\r\n {},\r\n );","IsDeferred":false},{"Name":"Using array filter and object assign","Code":"PRIMARY_SCOPES = [\u0027a\u0027, \u0027d\u0027]\r\navailableScopes = {\u0027a\u0027: \u0027A\u0027, \u0027b\u0027: \u0027B\u0027, \u0027c\u0027: \u0027C\u0027, \u0027d\u0027: \u0027D\u0027}\r\n\r\nconst output = {};\r\n Object.entries(availableScopes).forEach(([key, value]) =\u003E {\r\n if (!PRIMARY_SCOPES.includes(key)) {\r\n return;\r\n }\r\n Object.assign(output, { [key]: value });\r\n });\r\n return output;","IsDeferred":false}]}