Write a self-reproducing program for Tom's JavaScript Machine. This is a program
The latter three requirements could be dropped initially, but using extra JavaScript features is not necessary and can be distracting. Note that user-defined functions are not needed, but they can simplify life (a bit).
If you have a solution that has too long lines, then you are making good progress, but you should also try to improve that.
Here are three ways to cheat:
Put the program in the input and copy it | with Run |
---|---|
Find the program text in the web page and write it | with Challenge |
Use the ability to obtain the source code of a function (This also depends on how your browser's JavaScript engine formats source code.) | with Challenge |
Other things that I consider cheating, but less so, are:
These things are allowed in full JavaScript, but it is more instructive to find a solution without extras. However, a solution using these features can be considered a step in the right direction. Needless to say, it is not necessary to use these features.
The output features of Tom's JavaScript Machine were introduced to circumvent some technical problems, so you can concentrate on the real challenge.
In case you get stuck, you can look at some hints.