# JavaScript (ES6), 55 bytes <!-- language: lang-javascript --> a=>b=>'1OR 3AND X5OR'.replace(/\d/g,n=>n>>a+b&1?'N':'') [Try it online!][TIO-k9i5xs1t] [JavaScript (Node.js)]: https://nodejs.org [TIO-k9i5xs1t]: https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i7J1k7d0D9IwdjRz0UhwtQ/SF2vKLUgJzE5VUM/JkU/XSfP1i7Pzi5RO0nN0F7dT91KXV3zf3J@XnF@TqpeTn66RpqGgSYQaXJhCBpiCBpiU2kIVvkfAA "JavaScript (Node.js) – Try It Online" ### How? For each gate type, we use the sum of \$a\$ and \$b\$ to right-shift a bit mask. We test the least significant bit of the result to find out if we must return the complementary form of the gate. a | 1 | 0 | 1 | 0 | b | 1 | 1 | 0 | 0 | ------+---+-------+---+--------- a+b | 2 | 1 | 0 | decimal ------+---+-------+---+--------- NOR | 0 | 0 | 1 | 1 NAND | 0 | 1 | 1 | 3 XNOR | 1 | 0 | 1 | 5 ---------- # JavaScript (ES6), 55 bytes Using a template literal is just as long. <!-- language: lang-javascript --> a=>b=>['N'[a|b]]+`OR ${['N'[a&b]]}AND X${['N'[a^b]]}OR` [Try it online!][TIO-k9i64ltu] [JavaScript (Node.js)]: https://nodejs.org [TIO-k9i64ltu]: https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@z/R1i7J1i5a3U89OrEmKTZWO8E/SEGlGiKgBhSodfRzUYiAicSBRPyDEv4n5@cV5@ek6uXkp2ukaRhoApEmF4agIYagITaVhmCV/wE "JavaScript (Node.js) – Try It Online"