4 ms·
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.
by Bilal_io 3y ago
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.
- paulddraper 3y agoThe amazing thing is that the is-even package depends on the is-odd package. I would have thought the reverse, but ¯\_(ツ)_/¯
- sltkr 3y agoEven 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.