This repository was archived by the owner on Feb 20, 2019. It is now read-only.
File tree 3 files changed +29
-0
lines changed
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'
83
83
import timeSince from './timeSince'
84
84
import first from './first'
85
85
import mode from './mode-array'
86
+ import rollDice from './rollDice'
86
87
87
88
export {
88
89
reverseArrayInPlace ,
@@ -170,4 +171,5 @@ export {
170
171
timeSince ,
171
172
first ,
172
173
mode ,
174
+ rollDice ,
173
175
}
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