Open ClickCyber opened 3 years ago
What is %? I don't get it
Yes, please don't put file size over readability. The old code is perfectly readable, while this would introduce some weird percentage arithmetic. It's safer to write out the cases explicitly.
What I do like in your code is that return true
and return false
is programmed out explicitly instead of doing some hard-to-read magic like return n % 2 == 0
. Maybe you could make a PR that changes:
function isEven(number) {
...
to:
function isEven(number) {
if (isEvenInternal(number))
return true;
return false;
}
function isEvenInternal(number) {
...
the thing with modulus operator (%) is that its an untested operator and not fit for production environment, this code is very very professional and useful. We have over a million lines. Yes, that's the symbol of professionalism
The code supports up to 300K in addition to being long and unnecessary it can be shortened to 6 lines !! example :