m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-10 14:04:45 -0400
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2017-07-10 14:46:59 -0400
commit8cb2f0e3b007d64e91648d732741c1b0371407fb (patch)
tree4c3b7e7aa482e902a5e673a0ed3dbe5d1508d0f9 /src
parentb170693c5d8e73286f38e499a0ba91ee9bafa1bb (diff)
Implement die addition
Diffstat (limited to 'src')
-rw-r--r--src/dice.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/dice.js b/src/dice.js
index 2914317..bc75cb7 100644
--- a/src/dice.js
+++ b/src/dice.js
@@ -10,9 +10,16 @@ const d = (number, sides) => {
}
}
+const add = (die1, die2) => {
+ return () => {
+ return die1().concat(die2())
+ }
+}
+
const roll = (die) => {
return die().reduce((a, b) => (a + b))
}
exports.d = d
+exports.add = add
exports.roll = roll