• gkd@lemmy.ml
      link
      fedilink
      arrow-up
      8
      ·
      11 months ago

      You’d think so but look at the number of active downloads 😅

    • KoboldCoterie@pawb.social
      link
      fedilink
      English
      arrow-up
      3
      ·
      11 months ago

      Looking at their code, it’s really just a bunch of checks to make sure the variable passed is actually an integer that it can work with, followed by the solution:

      return (n % 2) === 1;

      I can’t think of a more efficient way to get the answer. It does seem like it’d take more time to download the package than to just write the function yourself, though.

      • Sunrosa@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        11 months ago

        Ohh. JS needs you to check the variable during runtime??? That’s… something. I guess that’s what you get for using dynamic typing everywhere. I still bet it’d be faster to do the function by hand though.