104

Well it can happen!!!

Comments
  • 16
    I swear the number of dependencies in JS projects is insane. Just with a little analytical thinking and problem solving, a typical JS developer would find a big difference in their source code.
  • 8
    Omg. The library even has a dependency on Is-number. Also the solution above works in python and php as well.
  • 15
    But what if I want to know if a number is even??
  • 24
    https://github.com/jonschlinkert/...

    I'm seriously considering creating "is-true" and "is-false" packages.

    Moar starz for me
  • 6
    @cafecortado testExpression(isTrue(isFalse(isOdd(myNumber))))
  • 1
    @aj7397 Could you tell me an example of dependency like this? And why did you think exactly to lodash?
  • 2
    @crisz
    Search for "npm leftpad"
  • 0
    Blazor is my new jam.
  • 14
    @zlot lol look at the code for is-even. It requires is-odd and returns

    !isOdd(i)
  • 7
    Whoever wrote that shit: “i’m a world-renowned open source author and have published some of the world’s best known npm packages”

    Companies: here, have the CTO job and $28k/mo
  • 0
    I wonder what it returns for isOdd(0) :)

    how do you check whether 0 is odd or even with this lib? :)
  • 0
    @netikras It looks like is-odd just returns false for 0. It just takes the absolute value, checks whether it's a valid integer, and returns (n % 2) === 1
  • 1
    you need a check that the var isn't 0 as well as that gives an even modulo in some langs.
  • 3
    @Parzi Javascript is one of those languages. As far as I can tell, isOdd(0) returns false and isEven(0) returns true.
  • 0
    I choose you.
  • 1
    @netikras

    evens and odds alternate. so starting on 1, which is odd, must mean that 0 is even.
  • 0
    i actually find this kinda interesting for other reasons. if we had a variable with a value "up to and including some arbitrarily large integer" n, then you could determine if that number is even or odd when adding it to another number, without necessarily knowing what the value of n is.

    so for example if
    your starting point m is even, then n's starting point MUST be odd, and vice versa.

    and if the set count of integers on the numberline is even or odd than that tells us something.

    for example if we start on m=4
    then n0=5 and lets say its set length is 2. so n1=7.

    we then need only m, n0, or set length, to determine the parity of n1.

    im tired and i dont know why im typing this.
  • 0
    @Wisecrack except that 0 is neither :)
  • 2
    @netikras would you explain to me why?

    it seems that if numbers alternate between even and odd, and 1 is odd then that *should* imply what precedes it is even. but what you're saying is no?

    why?
  • 2
    Wikipedia says zero is even number: https://en.m.wikipedia.org/wiki/...
  • 2
    @Wisecrack IDK, I was taught that in school :D

    And the https://wikiwand.com/en/... article explains WHY I was taught that and why am I wrong...

    Damn. You can't even trust your teachers :/

    My appologies
  • 1
    What happen to vanilla?
  • 2
    @mr-user come again?
  • 1
    Lol... JavaScript is actually a crazy language buh I love it tho.
  • 0
    It is a mystical pull. When i was trying our Ramda in a react project for the first time i found myself compelled to get into currying and composition to eliminate even the simplest of transforms.
Add Comment