On Sun, 20 Mar 2011 15:04:27 +0100, Jason Mulligan <[email protected]> wrote:

                return ((arg % 2) === 0) ? true : false;

Just on general principle, the "? true : false" part is completely unnecessary. The condition
is already a boolean, so just do:
  return ((arg % 2) === 0);

If arg is a non-integer number, this will return false. I assume arg should be an integer.
You can force that by instead doing:
  return ((arg & 1) === 0);
That converts arg1 to a 32-bit integer by truncation, and then tests whether bit 0 is clear.
I.e., 12.3 is even, 13.5 is odd.

If you are into brevity (which there isn't really a good reason for), you can even do
  return !(arg & 1);

/L
--
Lasse Reichstein Holst Nielsen - [email protected]

--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to