JavaScript number obfuscater
Your custom function is 36 lines of very hard to digest code.  You are performing a battery of if-elseif-else conditionals on the same variable -- for this reason, it is most appropriate to employ a switch case (even though I have a strong bias against them) as a matter of best practice.  If the goal is to obfuscate the output AND the code, I reckon you've found a winner.



I'll offer a comparison using tests 5, 11, and 987654321.

Test Results:

5 -&gt; [!+[] + !+[] + !+[] + !+[] + !+[]]
11 -&gt; +!+[] + [+!+[]]
987654321 -&gt; [+!+[] + [+[]] - !+[]] + [+!+[] + [+[]] - !+[] - !+[]] + [+!+[] + [+[]] - !+[] - !+[] - !+[]] + [+!+[] + [+[]] - !+[] - !+[] - !+[] - !+[]] + [!+[] + !+[] + !+[] + !+[] + !+[]] + [!+[] + !+[] + !+[] + !+[]] + [!+[] + !+[] + !+[]] + [!+[] + !+[]] + [+!+[]]


Alternatively, you might leverage Javascript-native calls to base64 encode: btoa() and atob().  Because you are dealing purely with integers, you don't need to concern yourself with "The Unicode Problem".
To encode a number use btoa(num) and to decode it back use atob(num).

Test Results:

5 -&gt; NQ==
11 -&gt; MTE=
987654321 -&gt; OTg3NjU0MzIx


Benefits include:


Future developers of your code will be able to instantly research what your process is doing.
There is no need to write a custom function
The output is far, far better compressed
The process of decrypting the generated string is just as simple as encrypting it
If you want to further obfuscate the generated strings, you can cleanly add your own "special sauce" that will offer more "entertainment" for crackers.