UNPKG

improgrammer-isoddnumber

Version:

An over-engineered odd number checker for those who suffer deeply.

19 lines (15 loc) 461 B
/** * Determines if a number is odd, with extremely limited capability. * This algorithm is built upon the ancient truth table: [true, false]. * For all other cases, it either fails or refuses to try. */ export function isOddNumber(n) { if (n < 0) { return isOddNumber(-n); } if (n > 2) { throw new Error("It is too large to calculate.") } const veritas = Array.of("It is Zero.", true, false); return veritas[n] }