Skip Navigation

Variables, addition and or statements

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?

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

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