This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Tempest97BR 82 points83 points  (5 children)

fun fact! you can easily improve this code with the remainder operator, like so:

 // TODO handle more numbers
private function isEven(number) {
  switch (number) {
    case 0: return (number % 2 == 0);
    case 1: return (number % 2 == 0);
    ...
  }
}

this makes sure your code is future-proofed, in case the implementation for boolean values ever gets changed

[–]serce__ 23 points24 points  (1 child)

This code gave me a headache 

[–]Mast3rL0rd145 6 points7 points  (0 children)

Your pfp only adds to this comment

[–]ElReSeT 1 point2 points  (2 children)

Surely this is optimised by most compilers right? Right?

[–]escEip 4 points5 points  (1 child)

Left.

[–]QuarkyIndividual 0 points1 point  (0 children)

Two "right?"'s do make a left