Ad

This places the undefined cases together on the left side of the initial evaluation enhancing readability, and then executes the primary test for 'eveness' on the right side of the comparison, again, enhancing readability.

Code
Diff
  • isEven = x => !x || !Number.isInteger(x) ? undefined : x % 2 ? false : true;
    
    // Previous iteration
    // isEven = x => x!=~~x?undefined:!(x%2);
    
    // Previous iteration
    // isEven = num => num % 2 === 0 ? true : num % 1 === 0 ? false : undefined;
    
    // Previous iteration
    
    // function isEven(num) {
    //   return num % 2 === 0 ? true : num % 1 === 0 ? false : undefined;
    // }
    
    • isEven = x => x!=~~x?undefined:!(x%2);
    • isEven = x => !x || !Number.isInteger(x) ? undefined : x % 2 ? false : true;
    • // Previous iteration
    • // isEven = x => x!=~~x?undefined:!(x%2);
    • // Previous iteration
    • // isEven = num => num % 2 === 0 ? true : num % 1 === 0 ? false : undefined;
    • // Previous iteration
    • // function isEven(num) {
    • // return num % 2 === 0 ? true : num % 1 === 0 ? false : undefined;
    • // }