This repository was archived by the owner on Feb 20, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ import copyArrayByValue from './copyArrayByValue'
8383import timeSince from './timeSince'
8484import first from './first'
8585import mode from './mode-array'
86+ import rollDice from './rollDice'
8687
8788export {
8889 reverseArrayInPlace ,
@@ -170,4 +171,5 @@ export {
170171 timeSince ,
171172 first ,
172173 mode ,
174+ rollDice ,
173175}
Original file line number Diff line number Diff line change 1+ export default rollDice
2+
3+ /**
4+ * Original Source: https://stackoverflow.com/questions/15603217/random-dice-nr-javascript
5+ *
6+ * This method will return a random value from rolling a dice.
7+ *
8+ * @return {number } - Random number between 1 and 6
9+ */
10+
11+ function rollDice ( ) {
12+ return Math . floor ( 6 * Math . random ( ) ) + 1
13+ }
Original file line number Diff line number Diff line change 1+ import test from 'ava'
2+ import { rollDice } from '../src'
3+
4+ test ( 'Dice value should not be greater than 6' , t => {
5+ const max = 6
6+ const diceValue = rollDice ( )
7+ t . false ( diceValue > max )
8+ } )
9+
10+ test ( 'Dice value should not be less than 1' , t => {
11+ const min = 1
12+ const diceValue = rollDice ( )
13+ t . false ( diceValue < min )
14+ } )
You can’t perform that action at this time.
0 commit comments