JavaScript (V8), 10296 bytes
-3 thanks to @Shaggy
-6 thanks to @tsh
I overlooked the rule allowing anonymous functions, so this generates a full program using either print
or console.log
with some extra tricks to handleprecaution for n
which is present in both instructions.
s=>`${S="print",S.match(s)?'eval("co\\156sole'co\\u006esole.log")'log':S}("\\${s.charCodeAt().toString(8)+s.slice(1)}")`