Hello, Im working on a generator and im trying to make this work. To explain my vision, I want r.roleBrawn to be added to s.subBrawnMod if s.subBrawnMod even exists, and if it doesnt, to instead just be added to 0, but I cant figure out how to format the syntax to make this work without doing not what I want it to do. Any help or advice?

  • BluePower
    link
    fedilink
    English
    arrow-up
    3
    ·
    5 months ago

    You can replace the square brackets inside with parentheses, otherwise it’ll just be interpreted as an array:

    [r.roleBrawn + (s.subBrawnMod || 0)]