This won't do anything your code doesn't already do, but ternary operators can save you a bunch of space when you've got a heap of variables to set conditionally. It doesn't make much difference in this case, but it's something to keep in mind if you've got a whole bunch of IFs with single statements after them (I also got rid of 'B' since it's the same as your default value): <script type="text/worker"> on("change:strength sheet:opened", function() { getAttrs(["strength"], function(values) { const str = values.strength; let strdie = (str == 'A') ? 12 : (str == 'C') ? 8 : (str == 'D') ? 6 : 10; setAttrs({strengthdie: strdie}); }); }); </script> There's some flexibility in the placement of parentheses, but this is the way I find it most logical to read: the part in (parentheses) is your logic condition, followed by a question mark. The first value after the ? is "if truthy", the second value is "if falsy". In this case, they're chained together, with the final value of "10" being landed on if each condition returns falsy. A non-chained ternary is easier to read: let x = (y !== 0) ? 'y is non-zero' : 'y is zero' Again, this doesn't do anything an IF statement can't do, but it will save you a bunch of typing & tabbing in the right places. Also, if your players are inputting the strength value manually, it might be worth considering this: let str = values.strength.toLowerCase(); let strdie = (str === 'a') ? 12 : (str === 'c') ? 8 : (str === 'd') ? 6 : 10; to handle people who don't like using their shift key.