Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
isEven(in){
If(in ==2) return true;
return isEven(in-2);
}
Welcome to functional programming -
Or with a bit attention to the architecture you're working on:
even = (n << 7) >> 7;
And it will contain 0 or 1, basically you shift left by 7 all the nunber bits, so when you shift back by 7 you can see that all the bits except the lsb will be zero. The possibile results will be 1 or 0. -
npm install is-even
const isEven = require('is-even');
... which actually depends on is-odd... -
@featurenotbug well, it's the actual module for this.. https://npmjs.com/package/is-even/
-
-
@Krokoklemme i suggest you take a look at bitwise tricks there's plenty of things you can do with those makes your life easier. there's a post full of those in stack overflow
-
@Verstrahlter @featurenotbug
Worst part is that is-odd has a dependency on is-number, which depends on kind-of.
That, and the fact that it gets 25k downloads per month.
You wish you had these skills (oc)
undefined