Wait, so there's an entire package that just divides by 2 an
Tue Oct 12, 2021 4:57am
d tells you if the result has a remainder? (Or shoot, you can just look at the last bit. If 1, not even.) It would kinda make sense in C, where the package could handle different numbers and number types, but isn't a number in JS just a number? (Been a while since I've looked at JS.)
One area where you never want to roll your own is in dates. Do you remember that despite being divisible by 4, that the year 2000 was not a leap year because it was also evenly divisible by 400? Even worse is time zones and daylight saving time... ALWAYS use a library for that.
/Programming Perl/ or "The Camel Book" is one of those books. The authors rather enjoyed Lord of the Rings and threw in references wherever they could. Way better than reading a manual.
32 million downloads: https://www.npmjs.com/package/is-even
But in a rational sense, that's a good philosophy. These days, I find myself looking to see if someone already created a package or library online before attempting to reinvent the wheel myself.
I think my first real experience wit... more
Wait, so there's an entire package that just divides by 2 an- Puckdropper,Tue Oct 12 2021 4:57am
It relies on another package called "is-odd".
This is the entire code for "is-even"
* Copyright (c) 2015, 2017, Jon Schlinkert.
* Released under the MIT License.
I guess that could be a good programming language feature. After all, you're better off with well used libraries than you are writing your own in most cases. (The number of "Apps" on Android that are rewritten versions of other apps--with no more features or even a different design is staggering. ... more