{"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},{"Name":"Using array filter and object assign SMALLER array first","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 PRIMARY_SCOPES.filter((scope) =\u003E scope in availableScopes).forEach((scope) =\u003E { \r\n Object.assign(output, { [scope]: availableScopes[scope] });\r\n });\r\n return output;","IsDeferred":false},{"Name":"Using array filter and object assign SMALLER array first, includes instead of in","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 PRIMARY_SCOPES.filter((scope) =\u003E Object.keys(availableScopes).includes(scope)).forEach((scope) =\u003E { \r\n Object.assign(output, { [scope]: availableScopes[scope] });\r\n });\r\n return output;","IsDeferred":false},{"Name":"Using array filter and reduce \u002B spread \u002B includes","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 Object.keys(availableScopes).includes(scope)).reduce(\r\n (result, scope) =\u003E ({\r\n ...result,\r\n [scope]: availableScopes[scope],\r\n }),\r\n {},\r\n );","IsDeferred":false}]}