Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I read the title and I sarcastically thought "ask JavaScript!" Your comment didn't disappoint. Importing the is-even package is the cherry on top.


The amazing thing is that the is-even package depends on the is-odd package.

I would have thought the reverse, but ¯\_(ツ)_/¯


It’s an odd choice for sure.


The is-odd package depends on is-number!


Even with plain Javascript, `Infinity % 2` evaluates to `NaN`, as it should.

And if you implement, e.g.:

   function IsEven(x) { return x % 2 == 0; }
   function IsOdd(x)  { return x % 2 == 1; }
Then IsEven(Infinity) == false and IsOdd(Infinity) == false, as expected.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: