ArnoldSmith86 / virtualtabletop

a virtual surface in the browser on which you can play board, dice and card games
https://virtualtabletop.io
GNU General Public License v3.0
173 stars 31 forks source link

added compute function `sum` #2275

Closed ArnoldSmith86 closed 2 months ago

ArnoldSmith86 commented 2 months ago

Takes an array, returns the sum of its elements. Should this be more fancy to handle values of an object or anything other than numbers in the array?

ArnoldSmith86 commented 2 months ago

PR-SERVER-BOT: You can play around with it here: https://test.virtualtabletop.io/PR-2275/pr-test (or any other room on that server)

96LawDawg commented 2 months ago

Takes an array, returns the sum of its elements. Should this be more fancy to handle values of an object or anything other than numbers in the array?

No.

Slightly unexpected outcome when not everything is a number. If no numbers before text, then you 0 and everything that follows all mashed together. If there are numbers, then text, then more numbers/text, you get the sum of the first group of numbers, then everything mashed together. I have no problem with this. If you are adding numbers and non-numbers, you can't expect valid results. This was just not what I was expecting. Works as it should on numerical arrays.

I added a button to the appropriate tutorial and will update the wiki when merged.