Skip to the content.

return true to win

alf.nu/ReturnTrue

season 1

id

function id(x) {
  return x;
}
â–¶ id(!0)
â–· true  // 2 char

reflexive

function reflexive(x) {
  return x != x;
}
â–¶ reflexive(NaN)
â–· true  // 3 chars

infinity

function infinity(x, y) {
  return x === y && 1 / x < 1 / y;
}
â–¶ infinity(-0,0)
â–· true  // 4 chars

transitive

function transitive(x, y, z) {
  return x && x == y && y == z && x != z;
}
â–¶ transitive([],0,[])
â–· true  // 7 chars

counter

function counter(f) {
  var a = f(),
    b = f();
  return a() == 1 && a() == 2 && a() == 3 && b() == 1 && b() == 2;
}
â–¶ counter((c=1)=>a=>c++)
â–· true // 13 chars

peano

function peano(x) {
  return x++ !== x && x++ === x;
}
â–¶ peano(9007199254740991)
â–· true  // 16 chars

array

function array(x, y) {
  return Array.isArray(x) && !(x instanceof Array) && !Array.isArray(y) && y instanceof Array;
}
â–¶ array([].__proto__,{__proto__:[]})
â–· true // 27 chars