• @[email protected]
    link
    fedilink
    English
    32 months ago

    does javascript not allow you to interpret integers as booleans in a conditions directly? seems it’d be simpler to just do math.round(math.random()), which should still get you true (1) or false (0) in equal likelihood. or am i missing something?

    • Admiral Patrick
      link
      fedilink
      English
      1
      edit-2
      2 months ago

      It’ll give you 1 ~= true or 0 ~= undefined, but I typically use Typescript which prefers actual booleans to boolean-ish

      • @[email protected]
        link
        fedilink
        English
        12 months ago

        huh. interesting. i wonder what number it’s actually storing for false then?