is-even icon indicating copy to clipboard operation
is-even copied to clipboard

code not Professional in file index.js

Open ClickCyber opened this issue 3 years ago • 3 comments

The code supports up to 300K in addition to being long and unnecessary it can be shortened to 6 lines !! example :

isEven = (n)=>{
    if (n % 2 == 1)
        return false;
    return true;
}

ClickCyber avatar Aug 20 '21 11:08 ClickCyber

What is %? I don't get it

samuelmarina avatar Aug 20 '21 13:08 samuelmarina

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) {
...

Hocuri avatar Aug 20 '21 16:08 Hocuri

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

Assassin-1234 avatar Aug 31 '21 05:08 Assassin-1234