{"ScriptPreparationCode":"var flag = {\r\n\ta: {\u0027truthy\u0027: true, \u0027falsey\u0027: false, \u0027only-in-a\u0027: true},\r\n\tb: {\u0027truthy\u0027: true, \u0027falsey\u0027: false, \u0027only-in-b\u0027: true},\r\n\tunused: {\u0027truthy\u0027: true, \u0027falsey\u0027: false},\r\n};\r\nvar rollNames = [\u0027a\u0027, \u0027b\u0027, \u0027missing\u0027];","TestCases":[{"Name":"reduce \u002B Array.prototype.concat","Code":"var other = rollNames.flatMap(rollName =\u003E\r\n // convert flag object to array containing the names of all fields with a truthy value\r\n Object.entries(flag[rollName] ?? {}).reduce((opts, [key, value]) =\u003E opts.concat(value ? key : []), [])\r\n ).reduce((unique, option) =\u003E {\r\n // ensure option entries are unique\r\n return unique.includes(option) ? unique : unique.concat(option);\r\n }, []);\r\n","IsDeferred":false},{"Name":"Array.prototype.flatMap","Code":"var other = [...new Set(rollNames.flatMap(rollName =\u003E\r\n // convert flag object to array containing the names of all fields with a truthy value\r\n Object.entries(flag[rollName] ?? {}).flatMap(([key, value]) =\u003E value ? [key] : [])\r\n ))];","IsDeferred":false}]}