There is a site called "Return True to Win" with interesting tasks for Javascript programmers. The goal is to find arguments to a given function that force it to return true.
The following is one of the tasks:
function total(x) {
return (x < x) && (x == x) && (x > x);
}
The users must find snippets for the value of x
that cause the function to return true. To test snippets, you call the function with your snippet as the parameter (i.e. total(<snippet>)
).
I found a 22-character solution:
{valueOf:_=>n++%3},n=0
Some people found the solution in 21 chars. I can't find out this solution. What is the solution in 21 chars?
{valueOf:Math.random}
works from time to time ... but I suspect that would infringe some rule... (or maybe not?) \$\endgroup\$