cybergirly
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
Persona3Reload@lemmy.blahaj.zone to 196@lemmy.blahaj.zoneEnglish · 6 months ago

Rule

lemmy.blahaj.zone

message-square
57
fedilink
389

Rule

lemmy.blahaj.zone

Persona3Reload@lemmy.blahaj.zone to 196@lemmy.blahaj.zoneEnglish · 6 months ago
message-square
57
fedilink
  • FiskFisk33@startrek.website
    link
    fedilink
    arrow-up
    14
    ·
    6 months ago

    oh of course there is

    https://www.npmjs.com/package/is-even

    (do take a look at the download stats)

    • Fiona@discuss.tchncs.de
      link
      fedilink
      arrow-up
      13
      ·
      edit-2
      6 months ago

      And that isn’t even the worst thing about it…

      The implementation looks like this:

      function isEven(i) {
        return !isOdd(i);
      };
      

      And yes, is-odd is a dependency that in turn depends on is-number…

    • Micromot@feddit.org
      link
      fedilink
      English
      arrow-up
      8
      arrow-down
      1
      ·
      edit-2
      6 months ago

      Can’t you just

      If (number % 2 == 0){return true}

      • blackn1ght@feddit.uk
        link
        fedilink
        arrow-up
        12
        ·
        6 months ago

        return number % 2 === 0

        • Micromot@feddit.org
          link
          fedilink
          English
          arrow-up
          1
          ·
          6 months ago

          Yeah, that’s even simpler

      • drake@lemmy.sdf.org
        link
        fedilink
        arrow-up
        6
        ·
        6 months ago

        but what if number isn’t an integer, or even a number at all? This code, and the improved code shared by the other user, could cause major problems under those conditions. Really, what you would want, is to validate that number is actually an integer before performing the modulo, and if it isn’t, you want to throw an exception, because something has gone wrong.

        That’s exactly what that NPM module does. And this is why it’s not a bad thing to use packages/modules for even very simple tasks, because they help to prevent us from making silly mistakes.

        • FiskFisk33@startrek.website
          link
          fedilink
          arrow-up
          1
          ·
          6 months ago

          ah the joys of loosely typed languages

        • Micromot@feddit.org
          link
          fedilink
          English
          arrow-up
          1
          ·
          6 months ago

          That would already cause an exception when calling the function because it has int number in the parameters

          • drake@lemmy.sdf.org
            link
            fedilink
            arrow-up
            4
            ·
            6 months ago

            Javascript doesn’t have strongly-typed variables

      • FiskFisk33@startrek.website
        link
        fedilink
        arrow-up
        5
        ·
        6 months ago

        yup, which is why I find the download stats truly horrifying

      • Python@programming.dev
        link
        fedilink
        arrow-up
        5
        ·
        6 months ago

        no

        • Micromot@feddit.org
          link
          fedilink
          English
          arrow-up
          2
          ·
          6 months ago

          ok

    • servobobo@feddit.nl
      link
      fedilink
      arrow-up
      7
      ·
      edit-2
      6 months ago

      “If it’s not an npm package it’s impossible”

      - JS devs, probably

    • tb_@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      6 months ago

      That’s a lot of downloads

196@lemmy.blahaj.zone

196@lemmy.blahaj.zone

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !196@lemmy.blahaj.zone

Be sure to follow the rule before you head out.


Rule: You must post before you leave.



Other rules

Behavior rules:

  • No bigotry (transphobia, racism, etc…)
  • No genocide denial
  • No support for authoritarian behaviour (incl. Tankies)
  • No namecalling
  • Accounts from lemmygrad.ml, threads.net, or hexbear.net are held to higher standards
  • Other things seen as cleary bad

Posting rules:

  • No AI generated content (DALL-E etc…)
  • No advertisements
  • No gore / violence
  • Mutual aid posts are not allowed

NSFW: NSFW content is permitted but it must be tagged and have content warnings. Anything that doesn’t adhere to this will be removed. Content warnings should be added like: [penis], [explicit description of sex]. Non-sexualized breasts of any gender are not considered inappropriate and therefore do not need to be blurred/tagged.

If you have any questions, feel free to contact us on our matrix channel or email.

Other 196’s:

  • !196@lemmy.world
  • !onehundredninetysix@lemmy.blahaj.zone
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 712 users / day
  • 2.95K users / week
  • 6.11K users / month
  • 18.4K users / 6 months
  • 1 local subscriber
  • 17.6K subscribers
  • 7.39K Posts
  • 48.6K Comments
  • Modlog
  • mods:
  • Moss@lemmy.blahaj.zone
  • greembow@lemmy.blahaj.zone
  • moss@lemmy.world
  • Queue@beehaw.org
  • funky-rodent [he/him]@lemmy.blahaj.zone
  • Peachy [they/she] @lemmy.blahaj.zone
  • greembow@lemmy.world
  • remotelove@lemmy.ca
  • A_Very_Big_Fan@lemm.ee
  • qaz@lemmy.blahaj.zone
  • A_Very_Big_Fan@lemmy.world
  • qaz@lemmy.sdf.org
  • qaz@lemmy.world
  • qaz@sh.itjust.works
  • BE: 0.19.5
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org