28
6

More than 3 years have passed since last update.

isEven というGitHubトレンドに突如現れたライブラリ。

プロジェクト

This is a 100% serious project,

そのプロジェクト。

中身がこれ

image.png

!?!?!

となる

作者

マジレス

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

しかし容赦はないコメント

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 != 1. Maybe you could make a PR that changes:

function isEven(number) {
    if (isEvenInternal(number))
        return true;
    return false;
}

function isEvenInternal(number) {
...

isOdd

is odd もある...。

これは別物

$ curl https://api.isevenapi.xyz/api/iseven/6/

{
  "iseven": true,
  "ad": "Buy isEvenCoin, the hottest new cryptocurrency!"
}

まとめ

意外とpull request と discussionが勉強になる かもしれない。

改善は続く...

image.png

色々なことを考える人がいるものだ。以上です。

28
6
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
6