File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 11// returns a random integer between min (included) and max (included)
22function randInt ( min , max ) {
3- return Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
3+ return Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
44}
55
66// returns a random float between min (included) and max (included)
@@ -15,19 +15,19 @@ function randItem(items) {
1515
1616// returns the number passed in with a precision number of digits after the decimal point
1717function toPrecision ( number , precision ) {
18- return + ( ( number ) . toFixed ( precision ) ) ;
18+ return + ( ( number ) . toFixed ( precision ) ) ;
1919}
2020
2121// shuffles items and returns a new array. Based on the modern Fisher-Yates shuffle algorithm
2222function shuffleItems ( items ) {
23- return items . reduce ( ( result , item , index ) => {
24- if ( index === items . length - 1 ) {
25- return result ;
23+ return items . reduce ( ( result , item , index ) => {
24+ if ( index === items . length - 1 ) {
25+ return result ;
2626 }
27-
28- const jindex = Math . floor ( Math . random ( ) * ( items . length - 1 - index + 1 ) ) + index ;
27+
28+ const jindex = Math . floor ( Math . random ( ) * ( items . length - 1 - index + 1 ) ) + index ;
2929 [ result [ index ] , result [ jindex ] ] = [ result [ jindex ] , result [ index ] ] ;
30-
30+
3131 return result ;
3232 } , items ) ;
3333}
You can’t perform that action at this time.
0 commit comments