From 31307362fac9a6d75a373463495aa688cfbc3cd1 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Fri, 14 Jul 2017 23:46:16 -0400 Subject: Define and use the pool function --- src/dice.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dice.js b/src/dice.js index c8a2572..5edc892 100644 --- a/src/dice.js +++ b/src/dice.js @@ -1,7 +1,11 @@ const constant = n => () => [n] +const pool = (die) => { + return die() +} + const roll = (die) => { - return die().reduce((a, b) => (a + b)) + return pool(die).reduce((a, b) => (a + b)) } const d = (number, sides) => { @@ -37,8 +41,10 @@ const subtract = (die1, die2) => { } } +exports.pool = pool +exports.roll = roll exports.constant = constant exports.d = d exports.add = add exports.subtract = subtract -exports.roll = roll +exports.negative = negative -- cgit v1.2.3